CODE FESTIVAL 2016 Grand Final(Parallel)

Submission #1004312

Source codeソースコード

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int dp[310][310],a[310][310],n;
ll pw[310];

int gauss() {
	int p=0;
	rep(i,0,n) {
		int fg=0;
		rep(j,p,n) if (a[j][i]) {
			rep(k,0,n) swap(a[p][k],a[j][k]); fg=1;
			break;
		}
		if (!fg) continue;
		rep(j,p+1,n) if (a[j][i]) {
			rep(k,0,n) a[j][k]^=a[p][k];
		}
		++p;
	}
	return p;
}
int main() {
	scanf("%d",&n); pw[0]=1;
	rep(i,1,n+1) pw[i]=pw[i-1]*2%mod;
	dp[0][0]=1;
	rep(j,0,n) rep(k,0,j+1) {
		dp[j+1][k+1]=(dp[j+1][k+1]+dp[j][k]*(pw[n]-pw[k]))%mod;
		dp[j+1][k]=(dp[j+1][k]+dp[j][k]*pw[k])%mod;
	}
	rep(i,0,n) rep(j,0,n) scanf("%d",&a[i][j]);
	int r=gauss(),ret=0;
	rep(i,r,n+1) ret=(ret+(ll)dp[n][i]*dp[i][r]%mod*powmod(2,n*n-i*n))%mod;
	ret=ret*powmod(dp[n][r],mod-2)%mod;
	if (ret<0) ret+=mod;
	printf("%lld\n",ret);
}

Submission

Task問題 H - AB=C Problem
User nameユーザ名 apiad
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1500
Source lengthソースコード長 1425 Byte
File nameファイル名
Exec time実行時間 14 ms
Memory usageメモリ使用量 896 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:58:21: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=]
printf("%lld\n",ret);
^
./Main.cpp:46:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n); pw[0]=1;
^
./Main.cpp:53:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,0,n) rep(j,0,n) scanf("%d",&a[i][j]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt
All 1500 / 1500 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 3 ms 384 KB
015.txt AC 3 ms 512 KB
016.txt AC 2 ms 384 KB
017.txt AC 5 ms 640 KB
018.txt AC 2 ms 384 KB
019.txt AC 1 ms 128 KB
020.txt AC 4 ms 512 KB
021.txt AC 13 ms 896 KB
022.txt AC 2 ms 384 KB
023.txt AC 10 ms 896 KB
024.txt AC 14 ms 896 KB
025.txt AC 13 ms 896 KB
026.txt AC 14 ms 896 KB
027.txt AC 12 ms 896 KB
028.txt AC 10 ms 896 KB
029.txt AC 13 ms 896 KB
030.txt AC 14 ms 896 KB
031.txt AC 13 ms 896 KB
032.txt AC 9 ms 896 KB
033.txt AC 14 ms 896 KB
034.txt AC 9 ms 896 KB
035.txt AC 6 ms 768 KB
036.txt AC 14 ms 896 KB
037.txt AC 12 ms 896 KB
038.txt AC 9 ms 896 KB
039.txt AC 14 ms 896 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 1 ms 128 KB