Submission #1036148
Source Code Expand
#define DEB #include<bits/stdc++.h> #define REP(i,m) for(int i=0;i<(m);++i) #define REPN(i,m,in) for(int i=(in);i<(m);++i) #define ALL(t) (t).begin(),(t).end() #define CLR(a) memset((a),0,sizeof(a)) #define pb push_back #define mp make_pair #define fr first #define sc second using namespace std; #ifdef DEB #define dump(x) cerr << #x << " = " << (x) << endl #define prl cerr<<"called:"<< __LINE__<<endl #define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl #define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl #define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;} #else #define dump(x) ; #define dumpR(x) ; #define dumpY(x) ; #define dumpG(x) ; #define prl ; template<class T> void debug(T a,T b){ ;} #endif template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; } template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; } typedef long long int lint; typedef pair<int,int> pi; namespace std{ template<class S,class T> ostream &operator <<(ostream& out,const pair<S,T>& a){ out<<'('<<a.fr<<','<<a.sc<<')'; return out; } } template<lint mod> struct Int_{ unsigned x; unsigned mpow(Int_ a,unsigned k){ Int_ res=1; while(k){ if(k&1) res=res*a; a=a*a; k>>=1; } return res.x; } unsigned inverse(Int_ a){ return mpow(a,mod-2); } Int_(): x(0) { } Int_(long long sig) { int sigt=sig%mod; if(sigt<0) sigt+=mod; x=sigt; } unsigned get() const { return (unsigned)x; } Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; } Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; } Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; } Int_ &operator=(Int_ that) { x=that.x; return *this;} Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;} bool operator==(Int_ that) const { return x==that.x; } bool operator!=(Int_ that) const { return x!=that.x; } Int_ operator-() const { return Int_(0)-Int_(*this);} Int_ operator+(Int_ that) const { return Int_(*this) += that; } Int_ operator-(Int_ that) const { return Int_(*this) -= that; } Int_ operator*(Int_ that) const { return Int_(*this) *= that; } Int_ operator/(Int_ that) const { return Int_(*this) /= that; } }; namespace std{ template<lint mod> ostream &operator <<(ostream& out,const Int_<mod>& a){ out<<a.get(); return out; } template<lint mod> istream &operator >>(istream& in,Int_<mod>& a){ in>>a.x; return in; } }; typedef Int_<1000000007> Int; //const int INF=5e8; int n; int c[305][305]; Int dp[305][305][305]; Int pw2[605*305]; int main(){ cin>>n; REP(i,n) REP(j,n) cin>>c[i][j]; pw2[0]=1; REP(i,n*2*n) pw2[i+1]=pw2[i]*2; int R=0; REP(i,n){ bool found=false; REPN(j,n,R) if(c[j][i]){ if(j>R) REP(k,n) swap(c[j][k],c[R][k]); found=true; break; } if(!found) continue; REPN(j,n,R+1) if(c[j][i]){ REP(k,n) c[j][k]^=c[R][k]; } ++R; } dp[0][0][0]=1; REP(i,n) REP(j,n) REP(k,n) if(dp[i][j][k].x){ Int val=dp[i][j][k]; dp[i+1][j][k]+=val*pw2[j]; if(j+R-k>=0) dp[i+1][j+1][k]+=val*(pw2[n]-pw2[j+R-k]); if(j+R-k>=0) dp[i+1][j+1][k+1]+=val*(pw2[j+R-k]-pw2[j]); } Int res=0; REP(j,n+1) res+=dp[n][j][R]*pw2[n*(n-j)]; cout<<res<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - AB=C Problem |
User | hogloid |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 3654 Byte |
Status | AC |
Exec Time | 269 ms |
Memory | 112128 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 | 150 ms | 111744 KB |
001.txt | AC | 149 ms | 111744 KB |
002.txt | AC | 148 ms | 111744 KB |
003.txt | AC | 148 ms | 111744 KB |
004.txt | AC | 149 ms | 111744 KB |
005.txt | AC | 149 ms | 111744 KB |
006.txt | AC | 150 ms | 111744 KB |
007.txt | AC | 148 ms | 111744 KB |
008.txt | AC | 149 ms | 111744 KB |
009.txt | AC | 149 ms | 111744 KB |
010.txt | AC | 148 ms | 111744 KB |
011.txt | AC | 150 ms | 111744 KB |
012.txt | AC | 152 ms | 111744 KB |
013.txt | AC | 149 ms | 111744 KB |
014.txt | AC | 157 ms | 111872 KB |
015.txt | AC | 159 ms | 112000 KB |
016.txt | AC | 152 ms | 111872 KB |
017.txt | AC | 172 ms | 112000 KB |
018.txt | AC | 152 ms | 111872 KB |
019.txt | AC | 150 ms | 111744 KB |
020.txt | AC | 170 ms | 112000 KB |
021.txt | AC | 263 ms | 112128 KB |
022.txt | AC | 151 ms | 111872 KB |
023.txt | AC | 230 ms | 112128 KB |
024.txt | AC | 219 ms | 112128 KB |
025.txt | AC | 269 ms | 112128 KB |
026.txt | AC | 262 ms | 112128 KB |
027.txt | AC | 265 ms | 112128 KB |
028.txt | AC | 215 ms | 112128 KB |
029.txt | AC | 268 ms | 112128 KB |
030.txt | AC | 265 ms | 112128 KB |
031.txt | AC | 269 ms | 112128 KB |
032.txt | AC | 204 ms | 112128 KB |
033.txt | AC | 253 ms | 112128 KB |
034.txt | AC | 203 ms | 112128 KB |
035.txt | AC | 179 ms | 112128 KB |
036.txt | AC | 209 ms | 112128 KB |
037.txt | AC | 198 ms | 112128 KB |
038.txt | AC | 206 ms | 112128 KB |
039.txt | AC | 210 ms | 112128 KB |
example0.txt | AC | 148 ms | 111744 KB |
example1.txt | AC | 148 ms | 111744 KB |