Submission #1153640
Source Code Expand
#include <cctype> #include <cstdio> #include <bitset> typedef long long i64; const int N = 2000 + 10, MOD = 1000000007; int nextInt() { char ch; while (!isdigit(ch = getchar())) {} int res = ch - '0'; while (isdigit(ch = getchar())) res = 10 * res + ch - '0'; return res; } int power(int base, int exp) { int res = 1; for (; exp; exp >>= 1) { if (exp & 1) res = (i64)res * base % MOD; base = (i64)base * base % MOD; } return res; } int fact[N], ifact[N]; inline int binom(int n, int m) { return m > n ? 0 : (i64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD; } int n; std::bitset<N> c[N]; int pivot[N]; int gauss() { int res = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) if (pivot[j] && c[i][j]) c[i] ^= c[pivot[j]]; for (int j = 1; j <= n; ++j) { if (!pivot[j] && c[i][j]) { pivot[j] = i; ++res; break; } } } return res; } int p[N]; int calc(int n, int m) { int res = 1; for (int i = 0; i < m; ++i) res = res * ((i64)p[n] - p[i]) % MOD; return res; } inline int solve(int n, int m) { return (i64)calc(n, m) * power(calc(m, m), MOD - 2) % MOD; } int f[N][N]; int main() { fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = (i64)fact[i - 1] * i % MOD; ifact[1] = 1; for (int i = 2; i < N; ++i) ifact[i] = ((i64)MOD - MOD / i) * ifact[MOD % i] % MOD; ifact[0] = 1; for (int i = 1; i < N; ++i) ifact[i] = (i64)ifact[i - 1] * ifact[i] % MOD; p[0] = 1; for (int i = 1; i < N; ++i) p[i] = 2 * p[i - 1] % MOD; scanf("%d", &n); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) c[i][j] = nextInt(); int rank = gauss(); f[0][0] = 1; for (int i = 1; i <= n; ++i) { f[i][0] = 1; for (int j = 1; j <= n; ++j) { int &cur = f[i][j] = (i64)f[i - 1][j] * p[j] % MOD; cur = (cur + (i64)f[i - 1][j - 1] * (p[n] - p[j - 1])) % MOD; } } int ans = 0; for (int i = rank; i <= n; ++i) { int cur = (i64)f[n][i] * power(solve(n, i), MOD - 2) % MOD; cur = (i64)cur * solve(n - rank, i - rank) % MOD; ans = (ans + (i64)cur * power(p[n - i], n)) % MOD; } printf("%d\n", (ans + MOD) % MOD); return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - AB=C Problem |
User | jiaqiyang |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 2283 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 3712 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:73:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1500 / 1500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 1 ms | 256 KB |
001.txt | AC | 1 ms | 256 KB |
002.txt | AC | 1 ms | 256 KB |
003.txt | AC | 1 ms | 256 KB |
004.txt | AC | 1 ms | 256 KB |
005.txt | AC | 1 ms | 256 KB |
006.txt | AC | 1 ms | 256 KB |
007.txt | AC | 1 ms | 256 KB |
008.txt | AC | 1 ms | 256 KB |
009.txt | AC | 1 ms | 256 KB |
010.txt | AC | 1 ms | 256 KB |
011.txt | AC | 1 ms | 256 KB |
012.txt | AC | 1 ms | 256 KB |
013.txt | AC | 1 ms | 256 KB |
014.txt | AC | 1 ms | 768 KB |
015.txt | AC | 1 ms | 768 KB |
016.txt | AC | 1 ms | 512 KB |
017.txt | AC | 3 ms | 1280 KB |
018.txt | AC | 1 ms | 512 KB |
019.txt | AC | 1 ms | 256 KB |
020.txt | AC | 2 ms | 896 KB |
021.txt | AC | 5 ms | 3712 KB |
022.txt | AC | 1 ms | 512 KB |
023.txt | AC | 5 ms | 3712 KB |
024.txt | AC | 5 ms | 3712 KB |
025.txt | AC | 5 ms | 3712 KB |
026.txt | AC | 5 ms | 3712 KB |
027.txt | AC | 5 ms | 3712 KB |
028.txt | AC | 5 ms | 3712 KB |
029.txt | AC | 5 ms | 3712 KB |
030.txt | AC | 5 ms | 3712 KB |
031.txt | AC | 5 ms | 3712 KB |
032.txt | AC | 5 ms | 3712 KB |
033.txt | AC | 5 ms | 3712 KB |
034.txt | AC | 5 ms | 3712 KB |
035.txt | AC | 3 ms | 1408 KB |
036.txt | AC | 5 ms | 3712 KB |
037.txt | AC | 4 ms | 3584 KB |
038.txt | AC | 5 ms | 3712 KB |
039.txt | AC | 5 ms | 3712 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |