結果
問題 | No.1677 mæx |
ユーザー | 夜 |
提出日時 | 2021-12-15 21:18:41 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 2,237 bytes |
コンパイル時間 | 864 ms |
コンパイル使用メモリ | 93,072 KB |
実行使用メモリ | 9,300 KB |
最終ジャッジ日時 | 2023-10-01 02:33:36 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 16 ms
7,332 KB |
testcase_05 | AC | 16 ms
7,388 KB |
testcase_06 | AC | 16 ms
7,380 KB |
testcase_07 | AC | 15 ms
7,316 KB |
testcase_08 | AC | 16 ms
7,356 KB |
testcase_09 | AC | 15 ms
7,572 KB |
testcase_10 | AC | 15 ms
7,348 KB |
testcase_11 | AC | 15 ms
7,464 KB |
testcase_12 | AC | 15 ms
7,340 KB |
testcase_13 | AC | 16 ms
7,356 KB |
testcase_14 | AC | 17 ms
7,460 KB |
testcase_15 | AC | 16 ms
7,440 KB |
testcase_16 | AC | 16 ms
7,344 KB |
testcase_17 | AC | 17 ms
7,452 KB |
testcase_18 | AC | 18 ms
7,412 KB |
testcase_19 | AC | 2 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 18 ms
9,300 KB |
コンパイルメッセージ
main.cpp: 関数 ‘t expression(int&)’ 内: main.cpp:98:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type] 98 | } | ^
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; string s; int k, i = 0; int e[3][3] = { {1,2,1},{2,0,0},{1,0,0} }; int a[3][3] = { {0,1,2},{1,1,2},{2,2,2} }; long long mod = 998244353; typedef struct { long long x, y, z; }t; t expression(int &i){ if (s[i] == 'm') { i++; if (s[i] == '?') { i += 3; t left = expression(i); i++; t right = expression(i); long long l[3] = { left.x,left.y,left.z }; long long r[3] = { right.x,right.y,right.z }; long long ans[3] = { 0,0,0 }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ans[e[i][j]] += l[i] * r[j] % mod; ans[a[i][j]] += l[i] * r[j] % mod; ans[e[i][j]] %= mod; ans[a[i][j]] %= mod; } } i++; return t{ ans[0],ans[1],ans[2] }; } else if (s[i] == 'e') { i += 3; t left = expression(i); i++; t right = expression(i); long long l[3] = { left.x,left.y,left.z }; long long r[3] = { right.x,right.y,right.z }; long long ans[3] = { 0,0,0 }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ans[e[i][j]] += l[i] * r[j] % mod; ans[e[i][j]] %= mod; } } i++; return t{ ans[0],ans[1],ans[2] }; } else if (s[i] == 'a') { i += 3; t left = expression(i); i++; t right = expression(i); long long l[3] = { left.x,left.y,left.z }; long long r[3] = { right.x,right.y,right.z }; long long ans[3] = { 0,0,0 }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ans[a[i][j]] += l[i] * r[j] % mod; ans[a[i][j]] %= mod; } } i++; return t{ ans[0],ans[1],ans[2] }; } } 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; t ans = expression(i); if (k == 0)cout << ans.x <<endl; if (k == 1)cout << ans.y << endl; if (k == 2)cout << ans.z << endl; return 0; }