Submission #530729

# Submission time Handle Problem Language Result Execution time Memory
530729 2022-02-26T15:26:15 Z ammar2000 Magnus (COCI18_magnus) C++17
50 / 50
2 ms 592 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define sc(x) scanf("%lld",&x)
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int dx[] = {1 , -1 , 0 , 0};
int dy[] = {0 , 0 , 1 , -1};
int MOD=1e9+7;
ll n;
string s;
int main()
{
   fast
   cin>>s;
   n=s.size();
   string h="HONI";
   ll in=0;
   ll ans=0;
   for (auto i:s)
   {
       if (in==3&&i==h[in])
        ans++;
        if(i==h[in])
            in++,in%=4;
   }
   cout <<ans<<"\n";
   // use scanf not cin
   return 0;
}

Compilation message

magnus.cpp: In function 'int main()':
magnus.cpp:30:8: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   30 |        if (in==3&&i==h[in])
      |        ^~
magnus.cpp:32:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |         if(i==h[in])
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 580 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 580 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 516 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 552 KB Output is correct