Submission #20009647


Source Code Expand

Copy
#include<bits/stdc++.h>
#define PB emplace_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 303, mod = 1e9 + 7;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar());
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
template<typename T>
bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
void qmo(int &x){x += x >> 31 & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL)a * a % mod)
		if(b & 1) res = (LL)res * a % mod;
	return res;
}
int n, r, pw2[N], dp[N][N], ans; bool vis[N];
bitset<N> bas[N], tmp;
int main(){
	read(n);
	for(int i = 0;i < n;++ i){
		for(int j = 0, ch;j < n;++ j){
			do ch = getchar(); while(ch != '0' && ch != '1');
			tmp[j] = ch - '0';
		}
		for(int j = 0;j < n;++ j) if(tmp[j]){
			if(vis[j]) tmp ^= bas[j];
			else {vis[j] = true; bas[j] = tmp; ++ r; break;}
		}
	} pw2[0] = 1;
	for(int i = 1;i <= n;++ i) qmo(pw2[i] = pw2[i-1] * 2 - mod);
	dp[0][0] = 1;
	for(int i = 0;i < n;++ i)
		for(int j = 0;j <= i;++ j){
			dp[i+1][j] = (dp[i+1][j] + (LL)dp[i][j] * pw2[j]) % mod;
			dp[i+1][j+1] = (dp[i+1][j+1] + (LL)dp[i][j] * (pw2[n] - pw2[j] + mod)) % mod;
		}
	for(int i = r;i <= n;++ i) ans = (ans + (LL)dp[n][i] * dp[i][r] % mod * ksm(2, n*(n-i))) % mod;
	printf("%lld\n", (LL)ans * ksm(dp[n][r], mod-2) % mod);
}

Submission Info

Submission Time
Task H - AB=C Problem
User yyybbbb
Language C++ (GCC 9.2.1)
Score 1500
Code Size 1616 Byte
Status AC
Exec Time 10 ms
Memory 4064 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 2
AC × 42
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 6 ms 3592 KB
001.txt AC 2 ms 3560 KB
002.txt AC 2 ms 3440 KB
003.txt AC 3 ms 3556 KB
004.txt AC 2 ms 3640 KB
005.txt AC 2 ms 3540 KB
006.txt AC 2 ms 3444 KB
007.txt AC 3 ms 3644 KB
008.txt AC 2 ms 3708 KB
009.txt AC 2 ms 3700 KB
010.txt AC 2 ms 3508 KB
011.txt AC 1 ms 3644 KB
012.txt AC 3 ms 3648 KB
013.txt AC 4 ms 3648 KB
014.txt AC 3 ms 3780 KB
015.txt AC 2 ms 3848 KB
016.txt AC 2 ms 3792 KB
017.txt AC 5 ms 3852 KB
018.txt AC 2 ms 3676 KB
019.txt AC 4 ms 3588 KB
020.txt AC 4 ms 3684 KB
021.txt AC 8 ms 3944 KB
022.txt AC 3 ms 3588 KB
023.txt AC 4 ms 3936 KB
024.txt AC 5 ms 3992 KB
025.txt AC 5 ms 3908 KB
026.txt AC 4 ms 3936 KB
027.txt AC 6 ms 4004 KB
028.txt AC 6 ms 3904 KB
029.txt AC 5 ms 3948 KB
030.txt AC 8 ms 3996 KB
031.txt AC 4 ms 3976 KB
032.txt AC 5 ms 3944 KB
033.txt AC 10 ms 4032 KB
034.txt AC 4 ms 3960 KB
035.txt AC 4 ms 3916 KB
036.txt AC 6 ms 4064 KB
037.txt AC 4 ms 3944 KB
038.txt AC 4 ms 3848 KB
039.txt AC 6 ms 3992 KB
example0.txt AC 2 ms 3652 KB
example1.txt AC 2 ms 3656 KB