Submission #1001126


Source Code Expand

#include <stdio.h>
#include <algorithm>
using namespace std;

const long long mod = 1000000007;

long long fpow(long long a, long long p)
{
	long long r = 1;
	while (p){
		if (p & 1) r = r * a % mod;
		a = a * a % mod;
		p /= 2;
	}
	return r;
}

int N, b[303][303];
long long first[303], mul[303];
long long cnt[303][303][303];

long long go(int n, int m, int r)
{
	if (r < 0) return 0;
	if (n == 0 || m == 0) return r == 0;
	if (cnt[n][m][r] != -1) return cnt[n][m][r];
	long long &res = cnt[n][m][r]; res = 0;
	res = go(n, m - 1, r-1);
	res = (res + go(n - 1, m - 1, r) * (fpow(2, n) - 1) % mod * fpow(2, m - 1)) % mod;
	return res;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) scanf("%d", &b[i][j]);

	for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++) for (int k = 0; k <= N; k++) cnt[i][j][k] = -1;

	int rank = 0;
	for (int i = 0, s = 0; i < N; i++, s++){
		bool g = 0;
		for (int j = i; j < N; j++) if (b[j][s]){
			if (i != j) for (int k = 0; k < N; k++) swap(b[i][k], b[j][k]);
			g = 1;
		}
		if (!g){
			rank++;
			continue;
		}
		for (int j = i + 1; j < N; j++) if (b[j][s]){
			for (int k = 0; k < N; k++) b[j][k] ^= b[i][k];
		}
	}

	first[1] = 1;
	mul[0] = 3;
	for (int i = 2; i <= N; i++){
		first[i] = first[i - 1] * fpow(2, i - 1) % mod * (fpow(2, i) - 1) % mod;
		long long sum = 0, now = first[i];
		for (int j = 0; j < i; j++){
			sum = (sum + now * go(i, i, j)) % mod;
			if (j < i-1) now = now * mul[j] % mod;
		}
		mul[i-1] = (fpow(2,i*i*2) - sum + mod)* fpow(now, mod - 2) % mod;
	}
	long long ans = first[N];
	for (int i = 0; i < rank; i++) ans = ans * mul[i] % mod;
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task H - AB=C Problem
User august14
Language C++14 (GCC 5.4.1)
Score 1500
Code Size 1754 Byte
Status AC
Exec Time 1198 ms
Memory 216192 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
./Main.cpp:36:79: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) scanf("%d", &b[i][j]);
                                                                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 2
AC × 42
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 256 KB
003.txt AC 1 ms 128 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 2 ms 384 KB
014.txt AC 78 ms 32512 KB
015.txt AC 93 ms 36992 KB
016.txt AC 24 ms 13056 KB
017.txt AC 387 ms 103552 KB
018.txt AC 21 ms 11648 KB
019.txt AC 2 ms 512 KB
020.txt AC 167 ms 56960 KB
021.txt AC 1129 ms 210560 KB
022.txt AC 24 ms 13056 KB
023.txt AC 1068 ms 203648 KB
024.txt AC 1177 ms 216192 KB
025.txt AC 1198 ms 216192 KB
026.txt AC 1172 ms 216192 KB
027.txt AC 1190 ms 216192 KB
028.txt AC 1160 ms 216192 KB
029.txt AC 1195 ms 216192 KB
030.txt AC 1196 ms 216192 KB
031.txt AC 1179 ms 216192 KB
032.txt AC 1169 ms 216192 KB
033.txt AC 1186 ms 216192 KB
034.txt AC 1164 ms 216192 KB
035.txt AC 558 ms 131968 KB
036.txt AC 1176 ms 216192 KB
037.txt AC 931 ms 184576 KB
038.txt AC 1147 ms 213376 KB
039.txt AC 1110 ms 209152 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 2 ms 512 KB