Submission #3671099
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i) #define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i) typedef long long ll; template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;} template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;} inline int read(){ int x; char c; int f=1; while((c=getchar())!='-' && (c>'9' || c<'0')); if(c=='-') f=-1,c=getchar(); x=c^'0'; while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0'); return x*f; } inline ll readll(){ ll x; char c; int f=1; while((c=getchar())!='-' && (c>'9' || c<'0')); if(c=='-') f=-1,c=getchar(); x=c^'0'; while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0'); return x*f; } const int maxn=3000+10,mod=1e9+7; bitset<maxn> C,Bas[maxn]; bool vis[maxn]; int Pw[maxn],dp[maxn][maxn]; int ksm(int x,int y){ int res=1; while(y){ if(y&1) res=(ll)res*x%mod; x=(ll)x*x%mod; y>>=1; } return res; } int main(){ int n=read(),R=0; REP(i,1,n){ REP(j,1,n) C[j]=read(); REP(j,1,n) if(C[j]){ if(vis[j]) C^=Bas[j]; else{ vis[j]=1,Bas[j]=C; ++R; break; } } } Pw[0]=1; REP(i,1,n) Pw[i]=(Pw[i-1]<<1)%mod; dp[0][0]=1; REP(i,1,n) REP(j,0,i){ dp[i][j]=(ll)dp[i-1][j]*Pw[j]%mod; if(j) dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-1]*(Pw[n]-Pw[j-1]+mod))%mod; } int ans=0; REP(i,R,n) ans=(ans+(ll)dp[n][i]*ksm(2,n*(n-i))%mod*dp[i][R])%mod; ans=(ll)ans*ksm(dp[n][R],mod-2)%mod; printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - AB=C Problem |
User | zhou888 |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 1640 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 3200 KB |
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 | 768 KB |
015.txt | AC | 2 ms | 768 KB |
016.txt | AC | 1 ms | 512 KB |
017.txt | AC | 3 ms | 3072 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 | 3072 KB |
022.txt | AC | 1 ms | 512 KB |
023.txt | AC | 4 ms | 3072 KB |
024.txt | AC | 5 ms | 3200 KB |
025.txt | AC | 5 ms | 3072 KB |
026.txt | AC | 5 ms | 3072 KB |
027.txt | AC | 4 ms | 3072 KB |
028.txt | AC | 4 ms | 3072 KB |
029.txt | AC | 5 ms | 3072 KB |
030.txt | AC | 5 ms | 3072 KB |
031.txt | AC | 5 ms | 3072 KB |
032.txt | AC | 4 ms | 3072 KB |
033.txt | AC | 5 ms | 3200 KB |
034.txt | AC | 4 ms | 3072 KB |
035.txt | AC | 3 ms | 3072 KB |
036.txt | AC | 5 ms | 3200 KB |
037.txt | AC | 4 ms | 3200 KB |
038.txt | AC | 4 ms | 3072 KB |
039.txt | AC | 5 ms | 3200 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |