답안 #1086303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086303 2024-09-10T05:58:03 Z toast12 Laugh Analysis (IOI16_laugh) C++14
0 / 100
1 ms 348 KB
#include "laugh.h"
#include <vector>
#include <string>
using namespace std;

int longest_laugh(string s)
{
    vector<int> pos;
    for (int i = 0; i < int(s.size()); i++) {
        if (s[i] == 'a' || s[i] == 'h')
            pos.push_back(i);
    }
    int l = pos[0], r = pos[0];
    int ans = 0;
    int cur = 1;
    while (r < int(s.size())) {
        if (pos[cur]-r > 1) {
            ans = max(ans, r-l+1);
            l = r = pos[cur];
            cur++;
        }
        else {
            if (s[pos[cur]] == s[r]) {
                ans = max(ans, r-l+1);
                l = r = pos[cur];
                cur++;
            }
            else {
                r++;
                ans = max(ans, r-l+1);
                cur++;
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '3'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '3'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB numbers differ - expected: '2', found: '3'
4 Halted 0 ms 0 KB -