Submission #598035

#TimeUsernameProblemLanguageResultExecution timeMemory
598035PyishtellLaugh Analysis (IOI16_laugh)C++17
100 / 100
4 ms596 KiB
#include "laugh.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; int longest_laugh(std::string s){ int count=0; int ans=0; for(int i=0; i<s.size()-1; i++){ if(s[i]=='h' && s[i+1]=='a') count++; else if(s[i]=='a' && s[i+1]=='h') count++; else{ ans=max(count+1,ans); count=0; } if(s[i]=='h' || s[i]=='a') ans=max(1,ans); } if(s[s.size()-1]=='h' || s[s.size()-1]=='a') ans=max(1,ans); ans=max(count+1,ans); return ans; }

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0; i<s.size()-1; i++){
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...