Submission #377552

#TimeUsernameProblemLanguageResultExecution timeMemory
377552marat0210Laugh Analysis (IOI16_laugh)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; int longest_laugh(string s) { if (s.size() == 1 and s[0] == 'a' or s[0] == 'h') { return 1; } int cnt = 0, mx = 0; for (int i = 0; i < s.size(); ++i) { if ((s[i] == 'a' and s[i - 1] == 'h') or (s[i] == 'h' and s[i - 1] == 'a')) { cnt += 2; } else if ((s[i] == 'a' and s[i - 1] == 'h' and i + 1 != s.size() and s[i + 1] == 'a') or (s[i] == 'h' and s[i - 1] == 'a' and i + 1 != s.size() and s[i + 1] == 'h')) { cnt++; mx = max(cnt, mx); cnt = 0; } } return mx; }

Compilation message (stderr)

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