Submission #584020

#TimeUsernameProblemLanguageResultExecution timeMemory
584020eecsSemafor (COI20_semafor)C++17
21 / 100
8 ms436 KiB
#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 (stderr)

semafor.cpp: In instantiation of '<lambda(auto:25, ll)> [with auto:25 = std::array<std::array<int, 32>, 32>; ll = long long int]':
semafor.cpp:44:27:   required from here
semafor.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::array<std::array<int, 32>, 32>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < A.size(); i++) {
      |                     ~~^~~~~~~~~~
semafor.cpp: In instantiation of '<lambda(auto:25, ll)> [with auto:25 = std::array<std::array<int, 10>, 10>; ll = long long int]':
semafor.cpp:52:51:   required from here
semafor.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::array<std::array<int, 10>, 10>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...