結果
問題 | No.1241 Eternal Tours |
ユーザー | rabimea |
提出日時 | 2023-01-27 06:35:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 929 ms / 6,000 ms |
コード長 | 2,303 bytes |
コンパイル時間 | 2,341 ms |
コンパイル使用メモリ | 205,428 KB |
実行使用メモリ | 42,180 KB |
最終ジャッジ日時 | 2023-09-10 03:25:14 |
合計ジャッジ時間 | 17,022 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 249 ms
19,408 KB |
testcase_03 | AC | 3 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 286 ms
12,012 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 74 ms
5,556 KB |
testcase_17 | AC | 928 ms
42,180 KB |
testcase_18 | AC | 657 ms
22,292 KB |
testcase_19 | AC | 670 ms
19,888 KB |
testcase_20 | AC | 5 ms
4,380 KB |
testcase_21 | AC | 15 ms
4,376 KB |
testcase_22 | AC | 821 ms
30,696 KB |
testcase_23 | AC | 19 ms
4,376 KB |
testcase_24 | AC | 1 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 1 ms
4,376 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 369 ms
19,520 KB |
testcase_29 | AC | 374 ms
19,428 KB |
testcase_30 | AC | 421 ms
19,528 KB |
testcase_31 | AC | 261 ms
11,220 KB |
testcase_32 | AC | 929 ms
42,180 KB |
testcase_33 | AC | 880 ms
21,308 KB |
testcase_34 | AC | 523 ms
19,448 KB |
testcase_35 | AC | 520 ms
19,332 KB |
testcase_36 | AC | 2 ms
4,376 KB |
testcase_37 | AC | 2 ms
4,384 KB |
testcase_38 | AC | 899 ms
21,524 KB |
testcase_39 | AC | 795 ms
20,284 KB |
testcase_40 | AC | 543 ms
19,308 KB |
testcase_41 | AC | 794 ms
41,964 KB |
testcase_42 | AC | 635 ms
20,288 KB |
testcase_43 | AC | 385 ms
19,416 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'; }