Submission #739657

#TimeUsernameProblemLanguageResultExecution timeMemory
739657mzvLaugh Analysis (IOI16_laugh)C++17
100 / 100
4 ms608 KiB
#include <bits/stdc++.h> #define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define endl '\n' using namespace std; /* ------------------------ hi lol ------------------------ */ int longest_laugh(string s) { int slen=s.length(); int ans=0,cur=0; if (s[0]=='h'||s[0]=='a') { cur++; ans++; } for (int i=1;i<slen;i++) { if ((s[i]=='a'&&s[i-1]=='h')||(s[i]=='h'&&s[i-1]=='a')) { cur++; } else if ((s[i]=='a')||(s[i]=='h')) { cur=1; } ans=max(ans,cur); } return ans; } /* int main() { cout << longest_laugh("ahaha") << endl; cout << longest_laugh("ahahrunawayahahsofasthah") << endl; cout << longest_laugh("ahahaahaha") << endl; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...