intinvertion(int v[], int k) { int r = 0; for (int i = 1; i <= k; i++) for (int j = i + 1; j <= k; j++) if (v[i] > v[j]) r++; return r; }
intmain() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]); for (int i = 1; i <= n; i++) p[i] = i; do { int term = 1; for (int i = 1; i <= n; i++) term *= a[i][p[i]]; term *= (invertion(p, n) & 1) ? -1 : 1; answer += term; } while (std::next_permutation(p + 1, p + n + 1)); printf("%d\n", answer); return0; }
template <typename T> voidswap(T &x, T &y) { T temp = x; x = y, y = temp; }
doubledetermination() { double r = 1; for (int i = 1; i <= n; i++) { if (equal(a[i][i], 0)) { int j; for (j = i + 1; j <= n; j++) if (!equal(a[j][i], 0)) break; if (j == n + 1) return0; r *= -1; for (int k = 1; k <= n; k++) swap(a[i][k], a[j][k]); } for (int j = i + 1; j <= n; j++) { double p = -(a[j][i] / a[i][i]); for (int k = i; k <= n; k++) a[j][k] += p * a[i][k]; } } for (int i = 1; i <= n; i++) r *= a[i][i]; return r; }