제출 #1323953

#제출 시각아이디문제언어결과실행 시간메모리
1323953kasamchiLaugh Analysis (IOI16_laugh)C++20
100 / 100
2 ms568 KiB
#include "laugh.h"
#include <bits/stdc++.h>
using namespace std;

int longest_laugh(string s) {
    int N = s.size();
    int ans = 0;
    for (int i = 0; i < N; ) {
        if (s[i] == 'a') {
            int j = i;
            while (j < N && (((j - i) % 2 == 0 && s[j] == 'a') || ((j - i) % 2 == 1 && s[j] == 'h'))) {
                j++;
            }
            ans = max(ans, j - i);
            i = j;
        } else if (s[i] == 'h') {
            int j = i;
            while (j < N && (((j - i) % 2 == 0 && s[j] == 'h') || ((j - i) % 2 == 1 && s[j] == 'a'))) {
                j++;
            }
            ans = max(ans, j - i);
            i = j;
        } else {
            i++;
        }
    }
    return ans;
}

컴파일 시 표준 에러 (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...