Submission #947718

# Submission time Handle Problem Language Result Execution time Memory
947718 2024-03-16T23:26:49 Z Volvox123 JOIOJI (JOI14_joioji) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int main()  
{
    int n;
    cin >> n;
    string poem;
    cin >> poem;

    unordered_map<int, int> counter;
    int max_length = 0;
    counter[0] = -1; 
    int diff = 0;
    for (int i = 0; i < n; i++) {
        if (poem[i] == 'J') {
            diff++;
        } else if (poem[i] == 'O') {
            diff--;
        }

        if (counter.find(diff) != counter.end()) {
            max_length = max(max_length, i - counter[diff]);
        } else {
            counter[diff] = i;
        }
    }

    cout << max_length << endl;

    return 0;
}

Compilation message

joioji.cpp:12:2: error: extended character   is not valid in an identifier
   12 |     counter[0] = -1;
      |  ^
joioji.cpp:12:5: error: extended character   is not valid in an identifier
   12 |     counter[0] = -1;
      |    ^
joioji.cpp:13:2: error: extended character   is not valid in an identifier
   13 |     int diff = 0;
      |  ^
joioji.cpp: In function 'int main()':
joioji.cpp:12:2: error: '\U000000a0' was not declared in this scope
   12 |     counter[0] = -1;
      |  ^
joioji.cpp:13:4: error: expected ';' before 'int'
   13 |     int diff = 0;
      |   ^ ~~~
      |   ;
joioji.cpp:16:13: error: 'diff' was not declared in this scope
   16 |             diff++;
      |             ^~~~
joioji.cpp:18:13: error: 'diff' was not declared in this scope
   18 |             diff--;
      |             ^~~~
joioji.cpp:21:26: error: 'diff' was not declared in this scope
   21 |         if (counter.find(diff) != counter.end()) {
      |                          ^~~~