제출 #1355064

#제출 시각아이디문제언어결과실행 시간메모리
1355064sanoChess Rush (CEOI20_chessrush)C++20
28 / 100
2101 ms259808 KiB
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#define NEK 1000000001
#define ll long long
#define vec vector
#define For(i, n) for(int i = 0; i < n; i++)
#define pii pair<int, int>
#define ff first
#define int ll
#define ss second
#define ld long double
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

vec<vec<int>> comb(vec<vec<int>>& a, vec<vec<int>>&b){
    int n = a.size();
    vec<vec<int>> vys(n, vec<int>(n, 0));
    For(i, n) For(j, n) For(k, n) vys[i][j] = (vys[i][j] + a[i][k] * b[k][j]) % mod;
    return vys;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r, c, q; cin >> r >> c >> q; r--;
    vec<vec<int>> mat[32];
    For(i, 32) mat[i].assign(c, vec<int>(c, 0));
    For(i, c) for(int j = i-1; j < c && j <= i+1; j++) if(j >= 0) mat[0][i][j] = 1;
    For(i, 31) mat[i+1] = comb(mat[i], mat[i]);
    vec<vec<int>> zac(c, vec<int>(c, 0));
    For(i, c) zac[i][i] = 1;
    For(i, 32) if(r & (1<<i)) zac = comb(zac, mat[i]);
    For(i, q){
        char t; cin >> t;
        if(t == 'K'){
            int c1, c2; cin >> c1 >> c2; c1--;c2--;
            cout << r << ' ' << zac[c2][c1] << endl;
        }
    }
    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…