Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
37976 | 申东铉 | 【S】T4 | C++ | 运行超时 | 15 | 1000 MS | 268 KB | 1686 | 2025-06-08 14:35:36 |
#include <bits/stdc++.h> #define int long long using namespace std; const int mod = 998244353; string s; int n,m; int a[202]; int b[202]; int a1,a2,a3; signed main () { cin >> s; n = s.size(); for (int i = 0;i < n;i++) { if (s[i] == '?') { m++; a[i] = m; } } for (int i = 0;i < (1ll << m);i++) { string st = s; for (int j = 0;j < n;j++) { if (st[j] == '?') { if ((1ll << (a[j] - 1)) & i) { st[j] = 'a'; } else { st[j] = 'b'; } } } st = st + st; st = st + st; int j = 1; int xl,xr; while (j < st.size()) { if (st[j - 1] != st[j]) { j++; } if (b[j % n]) { xl = b[j % n] + 1; xr = j; break; } b[j % n] = j; j += 2; } j = xl; // cout << st << ' ' << xl << ' ' << xr << endl; int A = 0,B = 0; while (j <= xr) { if (st[j - 1] != st[j]) { j++; } if (st[j] == 'a') { A++; } else { B++; } j += 2; } if (A - B < 0) { a1++; } else if (A - B > 0) { a2++; } else { a3++; } memset(b,0,sizeof(b)); } cout << a2 % mod << endl; cout << a3 % mod << endl; cout << a1 % mod << endl; return 0; }