Submission #51584

#TimeUsernameProblemLanguageResultExecution timeMemory
51584MatheusLealVLaugh Analysis (IOI16_laugh)C++17
100 / 100
7 ms2584 KiB
#include "laugh.h" #include <bits/stdc++.h> using namespace std; int longest_laugh(string s) { int ans = 0, prev = -1; char p; for(int i = 0; i < s.size(); i++) { if(s[i] != 'h' and s[i] != 'a') continue; int st = i; p = (s[i] == 'h' ? 'a' : 'h'); i ++; while(i < s.size() and s[i] == p) { i ++; if(p == 'h') p = 'a'; else p = 'h'; } ans = max(ans, i - st); i --; } return ans; }

Compilation message (stderr)

laugh.cpp: In function 'int longest_laugh(std::__cxx11::string)':
laugh.cpp:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < s.size(); i++)
                    ~~^~~~~~~~~~
laugh.cpp:22:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      while(i < s.size() and s[i] == p)
            ~~^~~~~~~~~~
laugh.cpp:8:15: warning: unused variable 'prev' [-Wunused-variable]
  int ans = 0, prev = -1;
               ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...