1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include <iostream> #include <algorithm> #include <string.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 55; #define ll long long int ll a[maxn][maxn],b[maxn][maxn];
ll determina(int n) { ll res = 1; for (int i = 1; i <= n; i++) { if (!b[i][i]) { bool flag = false; for (int j = i + 1; j <= n; j++) { if (b[j][i]){ flag = 1; for (int k = i; k < n; k++) swap(b[i][k],b[j][k]); res = -res; break; } } if (!flag) return 0; }
for (int j = i + 1; j <= n;j++) { while (b[j][i]) { ll t = b[i][i] / b[j][i]; for (int k = i; k <= n; k++) { b[i][k] -= t * b[j][k]; swap(b[i][k],b[j][k]); } res = -res; } } res *= b[i][i]; } return res; } int main() {
int n, m, k; while (scanf("%d%d%d",&n,&m,&k) != EOF) { memset(a, 0, sizeof a); memset(b,0,sizeof b); for (int i = 1; i <= m; i++) { int u, v; scanf("%d%d",&u,&v); a[u][v] = a[v][u] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i != j && !a[i][j]) { b[i][i]++; b[i][j] = -1; } } } n -= 1; ll ans = determina(n); printf("%ld\n",ans); } return 0; }
|