//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)a.size()
#define pf push_front
#define pb push_back
#define vt vector
#define s second
#define f first
#define nl '\n'
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vt<pii> rid = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
vt<pii> dir = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
const int N = 5e5, mod = 1e9 + 7;
const ll inf = 1e18;
double eps = 1e-15;
bool flg = 0;
string s;
int f(int tp, int l, int r) {
if (r < l) return 0;
if (s[l + 1] != (tp ? 'a' : 'i')) return 1;
if (s[l + 4] == '?' && s[l + 6] == '?') return 2;
if (s[l + 4] == '?') return f(tp, l + 6, r - 1) + 1;
else return f(tp, l + 4, r - 3) + 1;
}
void slv() {
cin >> s;
if (sz(s) == 1) {
cout << 1;
return;
}
int n = 0;
for (char c: s) if (c == '?') n++;
if (s[4] == s[6] && s[4] == '?') {
cout << 1;
return;
}
int cnt;
if (s[4] == '?') cnt = f((s[1] == 'a'), 6, sz(s) - 2);
else cnt = f((s[1] == 'a'), 4, sz(s) - 4);
cout << n - cnt;
}
main() {
//freopen("shops.in", "r", stdin);
//freopen("shops.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int tp = 1;
if (flg) cin >> tp;
while (tp--) {
slv();
}
}
Compilation message
Main.cpp:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
64 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
8668 KB |
Output is correct |
2 |
Correct |
25 ms |
8628 KB |
Output is correct |
3 |
Correct |
16 ms |
8668 KB |
Output is correct |
4 |
Correct |
16 ms |
8660 KB |
Output is correct |
5 |
Correct |
21 ms |
8572 KB |
Output is correct |
6 |
Correct |
17 ms |
8568 KB |
Output is correct |
7 |
Correct |
16 ms |
8668 KB |
Output is correct |
8 |
Correct |
18 ms |
8668 KB |
Output is correct |
9 |
Correct |
18 ms |
8680 KB |
Output is correct |
10 |
Correct |
17 ms |
8668 KB |
Output is correct |
11 |
Correct |
19 ms |
8668 KB |
Output is correct |
12 |
Correct |
21 ms |
8668 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |