# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
584027 |
2022-06-26T16:48:03 Z |
eecs |
Semafor (COI20_semafor) |
C++17 |
|
4000 ms |
4692 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 conv = [](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++) {
C[i ^ j] = (C[i ^ j] + 1LL * A[i] * B[j]) % P;
}
}
return C;
};
auto qp = [](auto A, ll k, auto op) {
auto B = A;
for (k--; k; k >>= 1, A = op(A, A)) {
if (k & 1) B = op(B, A);
}
return B;
};
int main() {
cin >> m >> n >> K >> X;
if (m == 1) {
auto get = [&](ll k) {
typedef array<int, 32> arr;
arr A{};
for (int i = 0; i < 5; i++) {
A[1 << i] = 1;
}
A = qp(A, k, conv);
array<array<int, 32>, 32> res{};
for (int i = 0; i < 32; i++) {
for (int j = 0; j < 32; j++) {
res[i][j] = A[i ^ j];
}
}
return res;
};
typedef array<array<int, 10>, 10> mat;
auto A = get(K);
mat tr;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
tr[i][j] = A[mask[i]][mask[j]];
}
}
mat res{};
res[0][X] = 1, res = mul(res, qp(tr, n / K, mul));
A = get(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);
}
auto get = [&](ll k) {
typedef array<int, 1024> arr;
arr A{};
for (int i = 0; i < 10; i++) {
A[1 << i] = 1;
}
A = qp(A, k, conv);
array<array<int, 1024>, 1024> res{};
for (int i = 0; i < 1024; i++) {
for (int j = 0; j < 1024; j++) {
res[i][j] = A[i ^ j];
}
}
return res;
};
typedef array<array<int, 100>, 100> mat;
auto A = get(K);
mat tr;
for (int i = 0; i < 100; i++) {
int x = mask[i / 10] << 5 | mask[i % 10];
for (int j = 0; j < 100; j++) {
int y = mask[j / 10] << 5 | mask[j % 10];
tr[i][j] = A[x][y];
}
}
mat res{};
res[0][X] = 1, res = mul(res, qp(tr, n / K, mul));
A = get(n % K);
for (int i = 0; i < 100; i++) {
int x = mask[i / 10] << 5 | mask[i % 10];
for (int j = 0; j < 100; j++) {
int y = mask[j / 10] << 5 | mask[j % 10];
tr[i][j] = A[x][y];
}
}
res = mul(res, tr);
for (int i = 0; i < 100; i++) {
cout << res[0][i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
4564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
4564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4061 ms |
4692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
4672 KB |
Output is correct |
2 |
Execution timed out |
4075 ms |
4692 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
4672 KB |
Output is correct |
2 |
Execution timed out |
4075 ms |
4692 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4061 ms |
4692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |