Submission #1088914
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit ) for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;
//#define DEBUG
ll power(ll x,ll y){
ll t=1;
while(y>0){
if(y%2) y-=1,t=t*x%mod;
else y/=2,x=x*x%mod;
}
return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif
int arr[305][305];
ll dp[305][305][305];
int gauss(int n){
int z=0;
REP(i,n){
int fl=z;
while(arr[fl][i]==0&&fl<n) fl++;
if(fl==n) continue;
REP(j,n) swap(arr[fl][j],arr[z][j]);
REPP(j,z+1,n) if(arr[j][i]){
REP(k,n) arr[j][k]^=arr[z][k];
}
z++;
}
return z;
}
ll pw[305*305];
int main(){
int n; scanf("%d",&n);
REP(i,n) REP(j,n) scanf("%d",&arr[i][j]);
REP(i,n) REP(j,n) if(i<j) swap(arr[i][j],arr[j][i]);
int p=gauss(n);
dp[0][0][p]=1;
pw[0]=1;
REPP(i,1,n*n+5) pw[i]=pw[i-1]*2%mod;
ll ans=0;
REP(i,n) REP(j,n+1) REP(k,n+1) if(dp[i][j][k]&&j<=k){
if(k<n){
dp[i+1][j+1][k+1]=(dp[i+1][j+1][k+1]+dp[i][j][k]*(pw[(n-k)]+mod-1)%mod*pw[k]%mod)%mod;
}
dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k]*(pw[j])%mod)%mod;
if(j<k){
dp[i+1][j+1][k]=(dp[i+1][j+1][k]+dp[i][j][k]*pw[j]%mod*(pw[(k-j)]+mod-1)%mod)%mod;
}
}
REP(j,n+1) ans+=dp[n][j][j]*pw[n*(n-j)]%mod;//,printf("%d %lld\n",j,dp[n][j][j]);
printf("%lld\n",ans%mod);
return 0;
}
Submission Info
Submission Time
2017-02-01 08:04:18+0900
Task
H - AB=C Problem
User
alecsyde
Language
C++14 (GCC 5.4.1)
Score
1500
Code Size
1953 Byte
Status
AC
Exec Time
349 ms
Memory
110464 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:56:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int n; scanf("%d",&n);
^
./Main.cpp:57:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,n) REP(j,n) scanf("%d",&arr[i][j]);
^
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
3 ms
256 KB
001.txt
AC
3 ms
256 KB
002.txt
AC
3 ms
256 KB
003.txt
AC
3 ms
256 KB
004.txt
AC
3 ms
256 KB
005.txt
AC
3 ms
256 KB
006.txt
AC
3 ms
256 KB
007.txt
AC
3 ms
256 KB
008.txt
AC
3 ms
256 KB
009.txt
AC
3 ms
256 KB
010.txt
AC
3 ms
256 KB
011.txt
AC
3 ms
256 KB
012.txt
AC
3 ms
256 KB
013.txt
AC
3 ms
256 KB
014.txt
AC
45 ms
16896 KB
015.txt
AC
53 ms
19328 KB
016.txt
AC
20 ms
6912 KB
017.txt
AC
136 ms
53120 KB
018.txt
AC
18 ms
6272 KB
019.txt
AC
3 ms
384 KB
020.txt
AC
83 ms
29312 KB
021.txt
AC
337 ms
107392 KB
022.txt
AC
19 ms
6912 KB
023.txt
AC
298 ms
103936 KB
024.txt
AC
302 ms
110080 KB
025.txt
AC
349 ms
110336 KB
026.txt
AC
342 ms
110336 KB
027.txt
AC
344 ms
110464 KB
028.txt
AC
299 ms
110464 KB
029.txt
AC
349 ms
110336 KB
030.txt
AC
342 ms
110336 KB
031.txt
AC
348 ms
110336 KB
032.txt
AC
288 ms
110464 KB
033.txt
AC
332 ms
110208 KB
034.txt
AC
288 ms
110464 KB
035.txt
AC
174 ms
67584 KB
036.txt
AC
294 ms
110080 KB
037.txt
AC
249 ms
94080 KB
038.txt
AC
289 ms
108928 KB
039.txt
AC
285 ms
106496 KB
example0.txt
AC
3 ms
256 KB
example1.txt
AC
3 ms
384 KB