# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584020 | 2022-06-26T16:38:40 Z | eecs | Semafor (COI20_semafor) | C++17 | 8 ms | 436 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int P = 1000000007, mask[] = {10, 2, 9, 7, 18, 21, 12, 3, 29, 23}; int m, X; ll n, K; auto mul = [](auto A, auto B) { int n = A.size(); decltype(A) C{}; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (A[i][j]) { for (int k = 0; k < n; k++) { C[i][k] = (C[i][k] + 1LL * A[i][j] * B[j][k]) % P; } } } return C; }; auto qp = [](auto A, ll k) { decltype(A) B{}; for (int i = 0; i < A.size(); i++) { B[i][i] = 1; } for (; k; k >>= 1, A = mul(A, A)) { if (k & 1) B = mul(B, A); } return B; }; int main() { cin >> m >> n >> K >> X; if (m == 1) { typedef array<array<int, 32>, 32> mat1; mat1 nxt{}; for (int i = 0; i < 32; i++) { for (int j = 0; j < 5; j++) { nxt[i][i ^ (1 << j)]++; } } typedef array<array<int, 10>, 10> mat2; auto A = qp(nxt, K); mat2 tr; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { tr[i][j] = A[mask[i]][mask[j]]; } } mat2 res{}; res[0][X] = 1, res = mul(res, qp(tr, n / K)); A = qp(nxt, n % K); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { tr[i][j] = A[mask[i]][mask[j]]; } } res = mul(res, tr); for (int i = 0; i < 10; i++) { cout << res[0][i] << "\n"; } exit(0); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 2 ms | 212 KB | Output is correct |
12 | Correct | 3 ms | 212 KB | Output is correct |
13 | Correct | 5 ms | 304 KB | Output is correct |
14 | Correct | 7 ms | 320 KB | Output is correct |
15 | Correct | 5 ms | 212 KB | Output is correct |
16 | Correct | 8 ms | 212 KB | Output is correct |
17 | Correct | 6 ms | 436 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 6 ms | 320 KB | Output is correct |
21 | Correct | 5 ms | 308 KB | Output is correct |
22 | Correct | 3 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |