Submission #1059247
Source Code Expand
// by ξ
// program sky :)
#include <vector>
#include <bitset>
#include <complex>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#define Rin register int
#define oo (c=getchar())
#define For(i,l,r) for(int _r=r,i=l;i<=_r;++i)
#define rep(i,l,r) for(int _r=r,i=l;i<_r;++i)
#define dto(i,r,l) for(int _l=l,i=r;i>=_l;--i)
#define ALL(V) V.begin(),V.end()
#define SZ(A) (int(A.size()))
#define pb push_back
#define mk make_pair
#define x first
#define y second
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int ,int> PII;
typedef complex<db> cpx;
typedef vector<int> VI;
typedef vector<PII> VII;
inline int IN(){
char c;Rin x=0;
for(;oo<48 && c^'-' || c>57;);bool f=c=='-';if(f)oo;
for(;c>47 && c<58;oo)x=(x<<3)+(x<<1)+c-48;if(f)x=-x;return x;
}
inline void hello(){
freopen("ha.in","r",stdin);
// freopen("ha.out","w",stdout);
}
const int mo=1e9+7;
int ans,n,r,pw[333*333],dp[333][333];
typedef bitset<333> vec;
vec base[333];
inline void inc(int &x,int y){
if((x+=y)>=mo)x-=mo;
}
inline int Pow(int x,int y){
int z=1;
for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)z=1ll*z*x%mo;
return z;
}
int main(){
// say hello
//hello();
n=IN();
rep(i,0,n){
vec v(0);
rep(j,0,n)v[j]=IN();
dto(k,n-1,0)if(v[k]){
if(base[k][k])v^=base[k];else{
base[k]=v;++r;
break;
}
}
}
*pw=1;
For(i,1,n*n)pw[i]=pw[i-1]*2%mo;
**dp=1;
rep(i,0,n)For(j,0,i)if(dp[i][j]){
inc(dp[i+1][j],pw[j]*1ll*dp[i][j]%mo);
inc(dp[i+1][j+1],(pw[n]-pw[j]+mo)*1ll*dp[i][j]%mo);
}
For(i,r,n){
inc(ans,1ll*dp[n][i]*pw[n*(n-i)]%mo*dp[i][r]%mo);
}
printf("%d\n",1ll*ans*Pow(dp[n][r],mo-2)%mo);
// never say goodbye
}
Submission Info
Submission Time
2017-01-09 12:18:26+0900
Task
H - AB=C Problem
User
remilia
Language
C++14 (GCC 5.4.1)
Score
1500
Code Size
1736 Byte
Status
AC
Exec Time
6 ms
Memory
896 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:84:45: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
printf("%d\n",1ll*ans*Pow(dp[n][r],mo-2)%mo);
^
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
128 KB
001.txt
AC
1 ms
128 KB
002.txt
AC
1 ms
128 KB
003.txt
AC
1 ms
128 KB
004.txt
AC
1 ms
128 KB
005.txt
AC
1 ms
128 KB
006.txt
AC
1 ms
128 KB
007.txt
AC
1 ms
128 KB
008.txt
AC
1 ms
128 KB
009.txt
AC
1 ms
128 KB
010.txt
AC
1 ms
128 KB
011.txt
AC
1 ms
128 KB
012.txt
AC
1 ms
128 KB
013.txt
AC
1 ms
128 KB
014.txt
AC
2 ms
384 KB
015.txt
AC
2 ms
384 KB
016.txt
AC
2 ms
256 KB
017.txt
AC
3 ms
640 KB
018.txt
AC
2 ms
256 KB
019.txt
AC
1 ms
128 KB
020.txt
AC
3 ms
512 KB
021.txt
AC
6 ms
896 KB
022.txt
AC
2 ms
256 KB
023.txt
AC
5 ms
896 KB
024.txt
AC
6 ms
896 KB
025.txt
AC
6 ms
896 KB
026.txt
AC
6 ms
896 KB
027.txt
AC
6 ms
896 KB
028.txt
AC
5 ms
896 KB
029.txt
AC
6 ms
896 KB
030.txt
AC
6 ms
896 KB
031.txt
AC
6 ms
896 KB
032.txt
AC
5 ms
896 KB
033.txt
AC
6 ms
896 KB
034.txt
AC
5 ms
896 KB
035.txt
AC
4 ms
640 KB
036.txt
AC
6 ms
896 KB
037.txt
AC
5 ms
896 KB
038.txt
AC
5 ms
896 KB
039.txt
AC
6 ms
896 KB
example0.txt
AC
1 ms
128 KB
example1.txt
AC
1 ms
128 KB