Submission #1160367


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 A - 1D Matching
User WuHongxun
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1742 Byte
Status RE
Exec Time 2103 ms
Memory 256 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 0 / 500
Status
WA × 2
WA × 2
TLE × 4
RE × 8
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, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt TLE 2103 ms 256 KB
001.txt TLE 2103 ms 256 KB
002.txt TLE 2103 ms 256 KB
003.txt TLE 2103 ms 256 KB
004.txt RE 1897 ms 256 KB
005.txt RE 869 ms 256 KB
006.txt RE 865 ms 256 KB
007.txt RE 868 ms 256 KB
008.txt RE 877 ms 256 KB
009.txt RE 870 ms 256 KB
010.txt RE 870 ms 256 KB
011.txt RE 884 ms 256 KB
example0.txt WA 1 ms 256 KB
example1.txt WA 1 ms 256 KB