답안 #947721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947721 2024-03-16T23:30:56 Z Volvox123 JOIOJI (JOI14_joioji) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int main()  
{
    int n;
    cin >> n;
    string poem;
    cin >> poem;
 
    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:10:2: error: extended character   is not valid in an identifier
   10 |     map<int, int> counter;
      |  ^
joioji.cpp:10:5: error: extended character   is not valid in an identifier
   10 |     map<int, int> counter;
      |    ^
joioji.cpp: In function 'int main()':
joioji.cpp:10:2: error: '\U000000a0' was not declared in this scope
   10 |     map<int, int> counter;
      |  ^
joioji.cpp:12:5: error: 'counter' was not declared in this scope
   12 |     counter[0] = -1;
      |     ^~~~~~~