Submission #710057

#TimeUsernameProblemLanguageResultExecution timeMemory
710057ToroTNLaugh Analysis (IOI16_laugh)C++14
100 / 100
6 ms596 KiB
#include "laugh.h" #include<bits/stdc++.h> //#include "grader.cpp" using namespace std; #define pb push_back int cnt; map<char,char> mp; int longest_laugh(std::string s) { mp['h']='a'; mp['a']='h'; int ans=0; for(int i=0;i<s.size();i++) { if(s[i]=='h'||s[i]=='a') { if(i==0||s[i-1]!='h'&&s[i-1]!='a') { cnt=1; }else { if(s[i]==mp[s[i-1]]) { ++cnt; }else { cnt=1; } } }else { cnt=0; } ans=max(ans,cnt); } return ans; }

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
laugh.cpp:17:33: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   17 |             if(i==0||s[i-1]!='h'&&s[i-1]!='a')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...