Submission #1052661
Source Code Expand
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; mt19937 mrand(random_device{} ()); int rnd(int x) { return mrand() % x; } typedef long double ld; typedef long long ll; #ifdef DEBUG #define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #else #define eprintf(...) ; #endif #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define TASK "text" const int inf = (int) 1.01e9; const ld eps = 1e-9; const ld pi = acos((ld) -1.0); const int mod = (int) 1e9 + 7; void add(int &x, int y) { if ((x += y) >= mod) { x -= mod; } } int mult(int x, int y) { return (long long) x * y % mod; } int myPower(int x, int pw) { int res = 1; for (; pw; pw >>= 1) { if (pw & 1) { res = mult(res, x); } x = mult(x, x); } return res; } void precalc() { } const int maxn = 310; int n; int a[maxn][maxn]; int read() { if (scanf("%d", &n) < 1) { return 0; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { scanf("%d", a[i] + j); } } return 1; } typedef unsigned long long type; const int maxk = (maxn + 63) / 64; type b[maxn][maxk]; int used[maxn]; int dp[maxn][maxn]; int two[maxn]; void solve() { two[0] = 1; for (int i = 1; i <= n; ++i) { two[i] = two[i - 1]; add(two[i], two[i]); } memset(dp, 0, sizeof(dp)); for (int a = 0; a <= n; ++a) { dp[a][0] = 1; for (int take = 0; take < n; ++take) { for (int r = min(take, a); r >= 0; --r) { int &cur = dp[a][r]; if (cur) { int k0 = two[n - a + r]; int k1 = two[n]; add(k1, mod - k0); add(dp[a][r + 1], mult(cur, k1)); cur = mult(cur, k0); } } } } for (int i = 0; i < n; ++i) { used[i] = 0; } int k = (n + 63) / 64; for (int i = 0; i < n; ++i) { for (int j = 0, p = 0; j < k; ++j) { auto &cur = b[i][j]; cur = 0; for (int iter = 0; iter < 64 && p < n; ++iter) { cur ^= ((type) a[i][p++] << iter); } } } int rank = 0; for (int c = 0; c < n; ++c) { int r = -1; for (int i = 0; i < n; ++i) { if (used[i] || !(b[i][c >> 6] & ((type) 1 << (c & 63)))) { continue; } r = i; break; } if (r == -1) { continue; } ++rank; used[r] = 1; for (int i = 0; i < n; ++i) { if (i == r) { continue; } if (b[i][c >> 6] & ((type) 1 << (c & 63))) { for (int j = 0; j < k; ++j) { b[i][j] ^= b[r][j]; } } } } eprintf("rank = %d\n", rank); int res = 0; for (int a = 0; a <= n; ++a) { add(res, mult(mult(dp[a][rank], dp[n][a]), myPower(dp[n][rank], mod - 2))); } printf("%d\n", res); } int main() { precalc(); #ifdef LOCAL freopen(TASK ".out", "w", stdout); assert(freopen(TASK ".in", "r", stdin)); #endif while (1) { if (!read()) { break; } solve(); #ifdef DEBUG eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC); #endif } return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - AB=C Problem |
User | XraY |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 3249 Byte |
Status | AC |
Exec Time | 120 ms |
Memory | 1024 KB |
Compile Error
./Main.cpp: In function ‘int read()’: ./Main.cpp:71:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", a[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 | 640 KB |
001.txt | AC | 3 ms | 640 KB |
002.txt | AC | 3 ms | 640 KB |
003.txt | AC | 3 ms | 640 KB |
004.txt | AC | 3 ms | 640 KB |
005.txt | AC | 3 ms | 640 KB |
006.txt | AC | 3 ms | 640 KB |
007.txt | AC | 3 ms | 640 KB |
008.txt | AC | 3 ms | 640 KB |
009.txt | AC | 3 ms | 640 KB |
010.txt | AC | 3 ms | 640 KB |
011.txt | AC | 3 ms | 640 KB |
012.txt | AC | 3 ms | 640 KB |
013.txt | AC | 3 ms | 640 KB |
014.txt | AC | 11 ms | 768 KB |
015.txt | AC | 12 ms | 768 KB |
016.txt | AC | 5 ms | 768 KB |
017.txt | AC | 43 ms | 896 KB |
018.txt | AC | 5 ms | 768 KB |
019.txt | AC | 3 ms | 640 KB |
020.txt | AC | 20 ms | 768 KB |
021.txt | AC | 115 ms | 1024 KB |
022.txt | AC | 5 ms | 768 KB |
023.txt | AC | 110 ms | 1024 KB |
024.txt | AC | 120 ms | 1024 KB |
025.txt | AC | 120 ms | 1024 KB |
026.txt | AC | 120 ms | 1024 KB |
027.txt | AC | 120 ms | 1024 KB |
028.txt | AC | 120 ms | 1024 KB |
029.txt | AC | 120 ms | 1024 KB |
030.txt | AC | 120 ms | 1024 KB |
031.txt | AC | 120 ms | 1024 KB |
032.txt | AC | 119 ms | 1024 KB |
033.txt | AC | 120 ms | 1024 KB |
034.txt | AC | 119 ms | 1024 KB |
035.txt | AC | 59 ms | 896 KB |
036.txt | AC | 120 ms | 1024 KB |
037.txt | AC | 96 ms | 1024 KB |
038.txt | AC | 117 ms | 1024 KB |
039.txt | AC | 114 ms | 1024 KB |
example0.txt | AC | 3 ms | 640 KB |
example1.txt | AC | 3 ms | 640 KB |