답안 #1086300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086300 2024-09-10T05:55:42 Z toast12 Laugh Analysis (IOI16_laugh) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> pos;
    for (int i = 0; i < int(s.length()); 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.length())) {
        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++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccjsCVqR.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqQgiEQ.o:laugh.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccjsCVqR.o: in function `main':
grader.cpp:(.text.startup+0x65): undefined reference to `longest_laugh(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status