This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair <int, int>
using namespace std;
const int N = 3e5 + 5;
int t,n,a[N],ans,curpos,cur;
map <char,char>nxt;
string s;
main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>s;
n = s.size();
s = "@" + s;
nxt['H'] = 'O';
nxt['O'] = 'N';
nxt['N'] = 'I';
nxt['I'] = 'H';
cur = 'I';
curpos = 1;
while (curpos <= n) {
if (s[curpos] != nxt[cur]) {
curpos++;
} else {
if (s[curpos] == 'I') ans++;
cur = s[curpos];
curpos++;
}
}
cout<<ans<<endl;
}
Compilation message (stderr)
magnus.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |