Submission #957157

#TimeUsernameProblemLanguageResultExecution timeMemory
957157ALTAKEXELaugh Analysis (IOI16_laugh)C++14
100 / 100
3 ms704 KiB
#include <bits/stdc++.h> using namespace std; bool check(char c) { return (c == 'h' || c == 'a'); } int longest_laugh(string s) { int ans = 0, mx = 0; for (int i = 0; i < s.size(); i++) { if (check(s[i])) { if (!i || !check(s[i - 1])) mx = 1; else mx = (s[i] != s[i - 1] ? mx + 1 : 1); } else mx = 0; ans = max(ans, mx); } return ans; }

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:10:23: 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(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...