Submission #980634

#TimeUsernameProblemLanguageResultExecution timeMemory
980634NoMercyLaugh Analysis (IOI16_laugh)C++17
100 / 100
3 ms1368 KiB
#include "laugh.h" #include <bits/stdc++.h> using namespace std; int longest_laugh(string S) { int N = S.size(); S = '-' + S; vector<int> dp(N + 1 , 0); for (int i = 1;i <= N;i ++) { if (S[i] == 'a' || S[i] == 'h') { dp[i] = 1; } else { dp[i] = 0; } if (S[i] == 'a' && S[i - 1] == 'h') { dp[i] += dp[i - 1]; } else if (S[i] == 'h' && S[i - 1] == 'a') { dp[i] += dp[i - 1]; } } int eded = *max_element(dp.begin() , dp.end()); return eded; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...