답안 #584020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584020 2022-06-26T16:38:40 Z eecs Semafor (COI20_semafor) C++17
21 / 100
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

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]
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -