Submission #3882573
Source Code Expand
#include <stdio.h> #include <stdlib.h> #define int long long #define p (int)(1e9 + 7) int MOD(int a){ a %= p; return a >= 0 ? a : a + p; } int rank(int **A, int N){ int i, j, k, l, *tmp; for(i = 0, j = 0; j < N; j++){ // printf("(i, j) = (%lld, %lld)\n", i, j); for(k = i; k < N && A[k][j] == 0; k++); // printf("k = %lld\n", k); if(k == N){ continue; } tmp = A[i]; A[i] = A[k]; A[k] = tmp; for(k = 0; k < N; k++){ if(i == k || A[k][j] == 0){ continue; } for(l = j; l < N; l++){ A[k][l] ^= A[i][l]; } } i++; } return i; } signed main(){ int N, R, i, j, k; scanf("%lld", &N); int **C = (int **)malloc(sizeof(int *) * N); for(i = 0; i < N; i++){ C[i] = (int *)malloc(sizeof(int) * N); for(j = 0; j < N; j++){ scanf("%lld", &C[i][j]); } } R = rank(C, N); // printf("R = %lld\n", R); int *pow2 = (int *)malloc(sizeof(int) * (N * N + 1)); pow2[0] = 1; for(i = 1; i <= N * N; i++){ pow2[i] = MOD(pow2[i - 1] * 2); } int ***dp = (int ***)malloc(sizeof(int **) * (N + 1)); for(i = 0; i <= N; i++){ dp[i] = (int **)malloc(sizeof(int *) * (N + 2)); for(j = 0; j <= N + 1; j++){ dp[i][j] = (int *)malloc(sizeof(int) * (N + 2)); for(k = 0; k <= N + 1; k++){ dp[i][j][k] = 0; } } } dp[0][0][0] = 1; for(i = 0; i < N; i++){ for(j = 0; j <= N; j++){ for(k = 0; k <= N; k++){ if(k > R || j < k){ dp[i][j][k] = 0; } else{ dp[i + 1][j][k] = MOD(dp[i + 1][j][k] + pow2[j] * dp[i][j][k]); dp[i + 1][j + 1][k] = MOD(dp[i + 1][j + 1][k] + MOD(pow2[N] - pow2[R - k + j]) * dp[i][j][k]); dp[i + 1][j + 1][k + 1] = MOD(dp[i + 1][j + 1][k + 1] + MOD(pow2[R - k + j] - pow2[j]) * dp[i][j][k]); } } } } /* for(i = 0; i <= N; i++){ for(j = 0; j <= N; j++){ for(k = 0; k <= N; k++){ printf("dp[%lld][%lld][%lld] = %lld\n", i, j, k, dp[i][j][k]); } } printf("\n"); } */ int ans = 0; for(j = 0; j <= N; j++){ ans = MOD(ans + pow2[N * (N - j)] * dp[N][j][R]); } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - AB=C Problem |
User | abc050 |
Language | C (GCC 5.4.1) |
Score | 1500 |
Code Size | 2125 Byte |
Status | AC |
Exec Time | 372 ms |
Memory | 218240 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:38:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &N); ^ ./Main.c:43:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &C[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 | 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 | 22 ms | 13056 KB |
015.txt | AC | 19 ms | 15744 KB |
016.txt | AC | 6 ms | 3456 KB |
017.txt | AC | 62 ms | 72448 KB |
018.txt | AC | 4 ms | 2944 KB |
019.txt | AC | 1 ms | 128 KB |
020.txt | AC | 47 ms | 29824 KB |
021.txt | AC | 324 ms | 209664 KB |
022.txt | AC | 4 ms | 3456 KB |
023.txt | AC | 208 ms | 198656 KB |
024.txt | AC | 372 ms | 218240 KB |
025.txt | AC | 324 ms | 218240 KB |
026.txt | AC | 351 ms | 218240 KB |
027.txt | AC | 298 ms | 218240 KB |
028.txt | AC | 195 ms | 218240 KB |
029.txt | AC | 331 ms | 218240 KB |
030.txt | AC | 346 ms | 218240 KB |
031.txt | AC | 314 ms | 218240 KB |
032.txt | AC | 180 ms | 218240 KB |
033.txt | AC | 360 ms | 218240 KB |
034.txt | AC | 174 ms | 218240 KB |
035.txt | AC | 85 ms | 104576 KB |
036.txt | AC | 372 ms | 218240 KB |
037.txt | AC | 294 ms | 171648 KB |
038.txt | AC | 178 ms | 213888 KB |
039.txt | AC | 353 ms | 206848 KB |
example0.txt | AC | 1 ms | 128 KB |
example1.txt | AC | 1 ms | 128 KB |