Submission #2093457


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,R;

const int MAT=402;
int mat[402][402];
ll dp[303][303][303];
ll p2[101010];
ll mo=1000000007;

int gf2_rank(int A[MAT][MAT],int n) { /* input */
	int i,j,k;
	FOR(i,n) {
		int be=i,mi=n+1;
		for(j=i;j<n;j++) {
			FOR(k,n) if(A[j][k]) break;
			if(k<mi) be=j,mi=k;
		}
		if(mi>=n) break;
		FOR(j,n) swap(A[i][j],A[be][j]);
		
		FOR(j,n) if(i!=j&&A[j][mi]) {
			FOR(k,n) A[j][k] ^= A[i][k];
		}
	}
	return i;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,101000) p2[i+1]=p2[i]*2%mo;
	
	cin>>N;
	FOR(y,N) FOR(x,N) cin>>mat[y][x];
	R=gf2_rank(mat,N);
	dp[0][0][0]=1;
	FOR(i,N) {
		FOR(x,R+1) FOR(y,N-R+1) if(dp[i][x][y]) {
			ll v=dp[i][x][y]*p2[x+y]%mo;
			// no new rank
			(dp[i+1][x][y]+=v)%=mo;
			// common rank
			if(x<R) (dp[i+1][x+1][y]+=v*(p2[R-x]+mo-1))%=mo;
			// single rank
			if(y<N-R) (dp[i+1][x][y+1]+=v*(p2[N-R-y]-p2[R-x]+mo))%=mo;
		}
	}
	
	//FOR(x,R+1) FOR(y,N-R+1) cout<<x<<" "<<y<<" "<<dp[N][x][y]<<endl;
	
	ll ret=0;
	FOR(y,N-R+1) (ret+=dp[N][R][y]*p2[N*(N-R-y)])%=mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task H - AB=C Problem
User kmjp
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1788 Byte
Status WA
Exec Time 208 ms
Memory 216576 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1500
Status
AC × 1
WA × 1
AC × 14
WA × 28
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 3 ms 1024 KB
001.txt AC 3 ms 1024 KB
002.txt AC 3 ms 3072 KB
003.txt WA 3 ms 3072 KB
004.txt AC 3 ms 3072 KB
005.txt AC 3 ms 3072 KB
006.txt WA 3 ms 3072 KB
007.txt WA 3 ms 3072 KB
008.txt AC 3 ms 3072 KB
009.txt AC 3 ms 3072 KB
010.txt WA 3 ms 3072 KB
011.txt WA 3 ms 3072 KB
012.txt WA 3 ms 3072 KB
013.txt AC 3 ms 3072 KB
014.txt WA 25 ms 83200 KB
015.txt WA 28 ms 89344 KB
016.txt WA 15 ms 52352 KB
017.txt WA 36 ms 148864 KB
018.txt WA 14 ms 50304 KB
019.txt AC 4 ms 7168 KB
020.txt WA 47 ms 111872 KB
021.txt WA 199 ms 214528 KB
022.txt WA 14 ms 52352 KB
023.txt WA 117 ms 210432 KB
024.txt WA 91 ms 216576 KB
025.txt WA 208 ms 216576 KB
026.txt WA 193 ms 216576 KB
027.txt WA 166 ms 216576 KB
028.txt WA 79 ms 216576 KB
029.txt WA 208 ms 216576 KB
030.txt WA 199 ms 216576 KB
031.txt WA 151 ms 216576 KB
032.txt WA 56 ms 216576 KB
033.txt WA 172 ms 216576 KB
034.txt AC 51 ms 216576 KB
035.txt AC 40 ms 169344 KB
036.txt AC 66 ms 216576 KB
037.txt AC 59 ms 200192 KB
038.txt WA 61 ms 214528 KB
039.txt WA 73 ms 214528 KB
example0.txt AC 3 ms 3072 KB
example1.txt WA 4 ms 7168 KB