Submission #494866

#TimeUsernameProblemLanguageResultExecution timeMemory
494866Christopher_Laugh Analysis (IOI16_laugh)C++17
100 / 100
10 ms6116 KiB
#include "laugh.h" #include <bits/stdc++.h> using namespace std; const int inf = 1e8; int longest_laugh(std::string s) { int n = (int) s.size(); vector<vector<int>> dp(n, vector<int>(2, -inf)); if (s[0] == 'a') dp[0][0] = 1; else if (s[0] == 'h') dp[0][1] = 1; for (int i = 1; i < (int) s.size(); ++i) { if (s[i] == 'a') { dp[i][0] = max(1, dp[i - 1][1] + 1); } else if (s[i] == 'h') { dp[i][1] = max(1, dp[i - 1][0] + 1); } } int mx = 0; for (int i = 0; i < n; ++i) { mx = max(mx, max(dp[i][0], dp[i][1])); } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...