Submission #1187571

#TimeUsernameProblemLanguageResultExecution timeMemory
1187571weakweakweakLaugh Analysis (IOI16_laugh)C++20
100 / 100
2 ms584 KiB
#include <bits/stdc++.h>
using namespace std;

int longest_laugh(std::string s) {
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a' or s[i] == 'h') {
            int j = i;
            while (j+1 < n and s[j+1] != s[j] and (s[j+1] == 'a' or s[j+1] == 'h')) j++;
            ans = max(ans, j-i+1);
            i = j;
        }
    }
    return ans;
}

Compilation message (stderr)

laugh.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
laugh_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...