제출 #1273339

#제출 시각아이디문제언어결과실행 시간메모리
1273339madamadam3캥거루 (CEOI16_kangaroo)C++20
36 / 100
1 ms1096 KiB
#include <bits/stdc++.h>

using namespace std;
using i128 = __int128_t;
const i128 MOD = 1e9 + 7;

signed main() {
    int N, S, T; cin >> N >> S >> T;
    i128 n = N, s = S, t = T; 

    vector<i128> r1({1});

    for (int i = 2; i <= n; i++) {
        vector<i128> nr1(i, 0);

        if (i % 2 == 0) for (int j = 1; j < i; j++) nr1[j] = (r1[j-1] + nr1[j-1]);
        else for (int j = i-2; j >= 1; j--) nr1[j] = (nr1[j+1] + r1[j]);

        r1 = nr1;
    }

    vector<vector<i128>> table(n, vector<i128>(n, 0));
    table[0] = r1;

    for (int i = 1; i < n; i++) {
        if (n % 2 == 0) {
            for (int j = i+1; j < n; j++) {
                table[i][j] = (table[i-1][j] + (table[i-1][j] - table[i-1][j-1]));
            }
        } else {
            int pt = 1;
            for (int j = i+1; j < n; j++) {
                table[i][j] = table[0][pt];
                pt++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            table[j][i] = table[i][j];
        }
    }

    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < n; j++) {
    //         cout << table[i][j] << "\t";
    //     }
    //     cout << "\n";
    // }

    cout << int(table[s-1][t-1] % MOD) << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...