Submission #508609

#TimeUsernameProblemLanguageResultExecution timeMemory
508609lukameladzeMagnus (COCI18_magnus)C++14
50 / 50
2 ms564 KiB
# 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...