Submission #412016

# Submission time Handle Problem Language Result Execution time Memory
412016 2021-05-26T12:14:16 Z 최서현(#7464) Semafor (COI20_semafor) C++17
0 / 100
3 ms 460 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define tiii tuple<int, int, int>
#define tiiii tuple<int, int, int, int>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
//#define DEBUG

using namespace std;

const int Q = (int)1e9 + 7;
const int X[10] = {3, 1, 18, 21, 9, 28, 6, 17, 30, 29};

vector<vector<int>> mul(const vector<vector<int>> &A, const vector<vector<int>> &B)
{
    int n = A.size();
    vector<vector<int>> C(n, vector<int>(n));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
        for(int k = 0; k < n; ++k)
        C[i][k] = (C[i][k] + 1ll * A[i][j] * B[j][k] % Q) % Q;
    return C;
}

vector<vector<int>> pow(vector<vector<int>> A, int x)
{
    int n = A.size();
    vector<vector<int>> R(n, vector<int>(n));
    for(int i = 0; i < n; ++i) R[i][i] = 1;
    while(x)
    {
        if(x & 1) R = mul(R, A);
        A = mul(A, A);
        x >>= 1;
    }
    return R;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int m, n, k, x; cin >> m >> n >> k >> x; n /= k;

    vector<vector<int>> A(32, vector<int>(32));
    for(int i = 0; i < 32; ++i)
        for(int j = 0; j < 32; ++j)
            if(__builtin_popcount(i ^ j) == 1) A[i][j] = 1;

    #ifdef DEBUG
        cout << endl;
        cout << "A" << endl;
        for(auto i : A)
        {
            for(auto j : i) cout << j << ' ';
            cout << endl;
        }
        cout << endl;
    #endif

    A = pow(A, k);

    #ifdef DEBUG
        cout << endl;
        cout << "A" << endl;
        for(auto i : A)
        {
            for(auto j : i) cout << j << ' ';
            cout << endl;
        }
        cout << endl;
    #endif

    vector<vector<int>> B(10, vector<int>(10));
    for(int i = 0; i < 10; ++i)
        for(int j = 0; j < 10; ++j)
        B[i][j] = A[X[i]][X[j]];
    B = pow(B, n);

    int ans = 0;
    for(int i = 0; i < 10; ++i) cout << B[x][i] << '\n';
}

Compilation message

semafor.cpp: In function 'int main()':
semafor.cpp:90:9: warning: unused variable 'ans' [-Wunused-variable]
   90 |     int ans = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -