結果
問題 | No.1677 mæx |
ユーザー | 👑 Nachia |
提出日時 | 2021-09-10 21:44:22 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 1,611 bytes |
コンパイル時間 | 748 ms |
コンパイル使用メモリ | 78,396 KB |
実行使用メモリ | 8,836 KB |
最終ジャッジ日時 | 2023-09-02 16:37:42 |
合計ジャッジ時間 | 1,867 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 7 ms
7,076 KB |
testcase_05 | AC | 7 ms
7,056 KB |
testcase_06 | AC | 6 ms
7,056 KB |
testcase_07 | AC | 6 ms
7,004 KB |
testcase_08 | AC | 7 ms
7,228 KB |
testcase_09 | AC | 7 ms
7,080 KB |
testcase_10 | AC | 7 ms
7,040 KB |
testcase_11 | AC | 7 ms
7,080 KB |
testcase_12 | AC | 7 ms
7,220 KB |
testcase_13 | AC | 7 ms
7,244 KB |
testcase_14 | AC | 7 ms
7,376 KB |
testcase_15 | AC | 7 ms
7,052 KB |
testcase_16 | AC | 7 ms
7,032 KB |
testcase_17 | AC | 8 ms
7,244 KB |
testcase_18 | AC | 7 ms
7,192 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 8 ms
8,836 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <atcoder/modint> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) using m32 = atcoder::modint998244353; struct Exp{ m32 A[3] = {}; }; int mex(int a, int b){ static const int mat[3][3] = { {1,2,1},{2,0,0},{1,0,0} }; return mat[a][b]; } Exp operator+(Exp a, Exp b){ Exp res; rep(i,3) res.A[i] = a.A[i] + b.A[i]; return res; } Exp maxExp(Exp a, Exp b){ Exp res; rep(i,3) rep(j,3) res.A[max(i,j)] += a.A[i] * b.A[j]; return res; } Exp mexExp(Exp a, Exp b){ Exp res; rep(i,3) rep(j,3) res.A[mex(i,j)] += a.A[i] * b.A[j]; return res; } Exp getExp(const string& S, int& p){ if(S[p] == '?'){ p++; return Exp{ {1,1,1} }; } if(S[p] == '0'){ p++; return Exp{ {1,0,0} }; } if(S[p] == '1'){ p++; return Exp{ {0,1,0} }; } if(S[p] == '2'){ p++; return Exp{ {0,0,1} }; } if(S[p] == 'm'){ p++; // m char nx = S[p]; p++; // ? p++; // x p++; // ( Exp a = getExp(S,p); p++; // , Exp b = getExp(S,p); p++; // ) if(nx == '?') return mexExp(a,b) + maxExp(a,b); if(nx == 'e') return mexExp(a,b); if(nx == 'a') return maxExp(a,b); } exit(1); } int main(){ string S; cin >> S; int p = 0; auto res = getExp(S,p); int k; cin >> k; cout << res.A[k].val() << endl; return 0; } struct ios_do_not_sync { ios_do_not_sync() { ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;