結果
問題 | No.1241 Eternal Tours |
ユーザー | rabimea |
提出日時 | 2023-01-27 06:35:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 941 ms / 6,000 ms |
コード長 | 2,303 bytes |
コンパイル時間 | 2,255 ms |
コンパイル使用メモリ | 209,504 KB |
実行使用メモリ | 42,212 KB |
最終ジャッジ日時 | 2024-06-27 19:21:10 |
合計ジャッジ時間 | 16,162 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 251 ms
19,584 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 3 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 287 ms
12,032 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 76 ms
6,940 KB |
testcase_17 | AC | 938 ms
42,212 KB |
testcase_18 | AC | 667 ms
22,376 KB |
testcase_19 | AC | 678 ms
20,256 KB |
testcase_20 | AC | 5 ms
6,940 KB |
testcase_21 | AC | 15 ms
6,940 KB |
testcase_22 | AC | 813 ms
30,948 KB |
testcase_23 | AC | 20 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 3 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 373 ms
19,712 KB |
testcase_29 | AC | 381 ms
19,584 KB |
testcase_30 | AC | 434 ms
19,584 KB |
testcase_31 | AC | 264 ms
11,392 KB |
testcase_32 | AC | 941 ms
42,080 KB |
testcase_33 | AC | 880 ms
21,612 KB |
testcase_34 | AC | 534 ms
19,584 KB |
testcase_35 | AC | 523 ms
19,584 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 916 ms
21,740 KB |
testcase_39 | AC | 816 ms
20,732 KB |
testcase_40 | AC | 568 ms
19,584 KB |
testcase_41 | AC | 794 ms
42,080 KB |
testcase_42 | AC | 646 ms
20,600 KB |
testcase_43 | AC | 398 ms
19,840 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back using vi = vector <int>; using ll = long long; using vl = vector <ll>; using pii = pair <int, int>; const ll mod = 998244353; //~ const ll mod = 1e9 + 7; ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a; for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; } const ll P = mod, G = 3; ll INV(ll x) { return qpow(x, P - 2); } void ntt(vl &a, int op = 1) { // P: 模数, G: 原根 int n = a.size(); for (int i = 1, j = 0; i < n - 1; ++i) { for (int s = n; j ^= s >>= 1, ~j & s;) {} if (i < j) swap(a[i], a[j]); } for (int i = 1; i < n; i *= 2) { ll u = qpow(G, (P - 1) / (i * 2)); if (op == -1) u = INV(u); for (int j = 0; j < n; j += i * 2) { ll w = 1; for (int k = 0; k < i; ++k, w = w * u % P) { int x = a[j + k], y = w * a[j + k + i] % P; #define modto(x) ({if ((x) >= P) (x) -= P;}) a[j + k] = x + y; modto(a[j + k]); a[j + k + i] = x - y + P; modto(a[j + k + i]); #undef modto }}} if (op == -1) { ll inv = INV(n); for (int i = 0; i < n; ++i) a[i] = a[i] * inv % P; } } void ntt2d(vector<vl> &mat) { for (auto &vec : mat) ntt(vec); int h = mat.size(), w = mat[0].size(); for (int j = 0; j < w; j++) { vl v(h); for (int i = 0; i < h; i++) v[i] = mat[i][j]; ntt(v); for (int i = 0; i < h; i++) mat[i][j] = v[i]; } } void ntt2dinv(vector<vl> &mat) { int h = mat.size(), w = mat[0].size(); for (int j = 0; j < w; j++) { vl v(h); for (int i = 0; i < h; i++) v[i] = mat[i][j]; ntt(v, -1); for (int i = 0; i < h; i++) mat[i][j] = v[i]; } for (auto &vec : mat) ntt(vec, -1); } int main() { ios :: sync_with_stdio(false); int x, y; cin >> x >> y; ll t; cin >> t; int a, b, c, d; cin >> a >> b >> c >> d; int n = (1 << (x + 1)); int m = (1 << (y + 1)); vector <vl> f(n, vl(m)); f[0][0] = f[0][1] = f[1][0] = f[n - 1][0] = f[0][m - 1] = 1; vector <vl> g(n, vl(m)); g[a][b] = g[n - a][m - b] = 1; g[n - a][b] = g[a][m - b] = mod - 1; ntt2d(f); ntt2d(g); for(int i = 0; i < n; i ++) for(int j = 0; j < m; j ++) { g[i][j] *= qpow(f[i][j], t); g[i][j] %= mod; } ntt2dinv(g); cout << g[c][d] << '\n'; }