Submission #1086299

# Submission time Handle Problem Language Result Execution time Memory
1086299 2024-09-10T05:55:09 Z toast12 Laugh Analysis (IOI16_laugh) C++14
Compilation error
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 < 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 < 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

laugh.cpp: In function 'int main()':
laugh.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
laugh.cpp:15:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     while (r < s.length()) {
      |            ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cchirMwl.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJE1sAp.o:laugh.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cchirMwl.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