結果
問題 | No.1677 mæx |
ユーザー | siro53 |
提出日時 | 2021-09-10 23:08:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 3,410 bytes |
コンパイル時間 | 2,293 ms |
コンパイル使用メモリ | 208,588 KB |
実行使用メモリ | 11,612 KB |
最終ジャッジ日時 | 2023-09-02 21:10:04 |
合計ジャッジ時間 | 3,720 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,372 KB |
testcase_01 | AC | 2 ms
4,372 KB |
testcase_02 | AC | 2 ms
4,372 KB |
testcase_03 | AC | 2 ms
4,368 KB |
testcase_04 | AC | 13 ms
8,956 KB |
testcase_05 | AC | 12 ms
8,968 KB |
testcase_06 | AC | 12 ms
8,904 KB |
testcase_07 | AC | 12 ms
8,848 KB |
testcase_08 | AC | 12 ms
9,052 KB |
testcase_09 | AC | 12 ms
8,940 KB |
testcase_10 | AC | 12 ms
8,904 KB |
testcase_11 | AC | 12 ms
9,168 KB |
testcase_12 | AC | 12 ms
8,964 KB |
testcase_13 | AC | 13 ms
8,780 KB |
testcase_14 | AC | 13 ms
9,024 KB |
testcase_15 | AC | 14 ms
8,900 KB |
testcase_16 | AC | 14 ms
8,796 KB |
testcase_17 | AC | 14 ms
8,980 KB |
testcase_18 | AC | 14 ms
8,908 KB |
testcase_19 | AC | 2 ms
4,372 KB |
testcase_20 | AC | 1 ms
4,368 KB |
testcase_21 | AC | 15 ms
11,612 KB |
コンパイルメッセージ
main.cpp: 関数 ‘VM f(int&)’ 内: main.cpp:142:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type] 142 | } | ^
ソースコード
#pragma region Macros #include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; } #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; for(int i = 0; i < (int)v.size(); i++) { if(i) { os << ','; } os << v[i]; } os << '}'; return os; } void debugg() { cerr << endl; } template <class T, class... Args> void debugg(const T &x, const Args &... args) { cerr << " " << x; debugg(args...); } #define debug(...) \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__) #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif struct Setup { Setup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } __Setup; using ll = long long; #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define FOR(i, a, b) for(int i = (a); i < int(b); i++) #define REP(i, n) FOR(i, 0, n) const int INF = 1 << 30; const ll LLINF = 1LL << 60; constexpr int MOD = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; void Case(int i) { cout << "Case #" << i << ": "; } int popcount(int x) { return __builtin_popcount(x); } ll popcount(ll x) { return __builtin_popcountll(x); } #pragma endregion Macros #include <atcoder/modint> using mint = atcoder::modint998244353; using VM = vector<mint>; string s; int K; VM MAX(VM A, VM B) { vector<mint> res(3, 0); REP(i, 3) REP(j, 3) { res[max(i, j)] += A[i] * B[j]; } return res; } VM MEX(VM A, VM B) { vector<mint> res(3, 0); vector<int> f(3, 0); REP(i, 3) REP(j, 3) { REP(k, 3) f[k] = 0; f[i] = f[j] = 1; REP(k, 3) if(f[k] == 0) { res[k] += A[i] * B[j]; break; } } return res; } VM f(int &i) { int res = 0; if(s[i] == 'm') { i++; if(s[i] == 'a') { i += 3; auto a = f(i); i++; auto b = f(i); i++; return MAX(a, b); } else if(s[i] == 'e') { i += 3; auto a = f(i); i++; auto b = f(i); i++; return MEX(a, b); } else if(s[i] == '?') { i += 3; auto a = f(i); i++; auto b = f(i); i++; auto res1 = MAX(a, b); auto res2 = MEX(a, b); REP(j, 3) res1[j] += res2[j]; return res1; } } else if(s[i] == '0') { i++; return {1, 0, 0}; } else if(s[i] == '1') { i++; return {0, 1, 0}; } else if(s[i] == '2') { i++; return {0, 0, 1}; } else { i++; return {1, 1, 1}; } } int main() { cin >> s >> K; int idx = 0; auto ans = f(idx); cout << ans[K].val() << endl; }