Submission #1124370

#TimeUsernameProblemLanguageResultExecution timeMemory
1124370caf_sqLaugh Analysis (IOI16_laugh)C++20
100 / 100
3 ms840 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int longest_laugh(string S) {
  string t;
  int ans = 0;
  for(auto &i : S) {
    if(i == 'a') {
      if(t.empty() || t.back() == 'h') { t += 'a'; }
      else { t = "a"; }
    }
    else if(i == 'h') {
      if(t.empty() || t.back() == 'a') { t += 'h'; }
      else { t = "h"; }
    }
    else { t.clear(); }
    ans = max(ans, (int)t.size());
  }

  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...