Submission #1086302

#TimeUsernameProblemLanguageResultExecution timeMemory
1086302toast12Laugh Analysis (IOI16_laugh)C++14
0 / 100
1 ms348 KiB
#include "laugh.h" #include <vector> #include <string> using namespace std; int longest_laugh(string s) { vector<int> pos; for (int i = 0; i < int(s.size()); i++) { if (s[i] == 'a' || s[i] == 'h') pos.push_back(i); } int l = pos[0], r = pos[0]; int ans = 0; int cur = 1; while (r < int(s.size())) { if (pos[cur]-r > 1) { ans = max(ans, r-l+1); l = r = pos[cur]; cur++; } else { if (s[pos[cur]] == s[r]) { ans = max(ans, r-l+1); l = r = pos[cur]; cur++; } else { r++; ans = max(ans, r-l+1); cur++; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...