Submission #1160370
Source Code Expand
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 310, mod = 1e9 + 7;
bitset<N> c[N];
int n, C = 0;
bool vis[N];
void init() {
rep(i,1,n) {
int t = 0;
rep(j,1,n) if (!vis[j] && c[j][i]) { t = j; break; }
if (!t) continue; if (t != i) swap(c[t], c[i]);
vis[i] = true, C++;
rep(j,1,n) if (!vis[j] && c[j][i]) c[j] ^= c[i];
}
}
int pw[N * N], f[N][N];
int F[N][N];
int Pw(int a, int b) {
int w = 1;
for(;b;b >>= 1, a = 1LL * a * a % mod) if (b & 1)
w = 1LL * w * a % mod;
return w;
}
int g(int n, int r) { return 1LL * f[n][r] * Pw(f[r][r], mod - 2) % mod; }
int main() {
scanf("%d",&n);
rep(i,1,n) rep(j,1,n) { int x; scanf("%d",&x); c[i][j] = x; }
init();
pw[0] = 1; rep(i,1,n * n) pw[i] = (pw[i - 1] << 1) % mod;
rep(i,0,n) {
F[i][0] = 1;
rep(j,1,i)
F[i][j] = (1LL * F[i - 1][j - 1] * (pw[n] - pw[j - 1]) + 1LL * F[i - 1][j] * pw[j]) % mod;
}
rep(i,0,n) {
f[i][0] = 1;
rep(j,1,i)
f[i][j] = 1LL * f[i][j - 1] * (pw[i] - pw[j - 1]) % mod;
}
int ans = 0;
rep(j,C,n) ans = (ans + 1LL * F[n][j] * g(j, C) % mod * 1LL * Pw(g(n, C), mod - 2) % mod * pw[n * (n - j)]) % mod;
if (ans < 0) ans += mod;
cout <<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
H - AB=C Problem |
User |
WuHongxun |
Language |
C++14 (GCC 5.4.1) |
Score |
1500 |
Code Size |
1742 Byte |
Status |
AC |
Exec Time |
10 ms |
Memory |
1408 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:48:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:49:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,1,n) rep(j,1,n) { int x; scanf("%d",&x); c[i][j] = x; }
^
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 |
2 ms |
640 KB |
015.txt |
AC |
3 ms |
640 KB |
016.txt |
AC |
2 ms |
512 KB |
017.txt |
AC |
5 ms |
896 KB |
018.txt |
AC |
2 ms |
384 KB |
019.txt |
AC |
1 ms |
256 KB |
020.txt |
AC |
3 ms |
768 KB |
021.txt |
AC |
9 ms |
1280 KB |
022.txt |
AC |
2 ms |
512 KB |
023.txt |
AC |
9 ms |
1280 KB |
024.txt |
AC |
10 ms |
1408 KB |
025.txt |
AC |
10 ms |
1408 KB |
026.txt |
AC |
10 ms |
1408 KB |
027.txt |
AC |
10 ms |
1408 KB |
028.txt |
AC |
10 ms |
1408 KB |
029.txt |
AC |
10 ms |
1408 KB |
030.txt |
AC |
10 ms |
1408 KB |
031.txt |
AC |
10 ms |
1408 KB |
032.txt |
AC |
9 ms |
1408 KB |
033.txt |
AC |
10 ms |
1408 KB |
034.txt |
AC |
9 ms |
1408 KB |
035.txt |
AC |
6 ms |
1024 KB |
036.txt |
AC |
10 ms |
1408 KB |
037.txt |
AC |
8 ms |
1280 KB |
038.txt |
AC |
9 ms |
1280 KB |
039.txt |
AC |
9 ms |
1280 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |