| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1287252 | TrieTr | JOIOJI (JOI14_joioji) | C++20 | 41 ms | 6796 KiB |
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template <class X, class Y> bool mini(X& x, Y y) {return x > y ? x = y, true : false;}
template <class X, class Y> bool maxi(X& x, Y y) {return x < y ? x = y, true : false;}
const int N = 1e6 + 5;
int n;
string s;
array<int, 3> state;
map<array<int, 3>, int> mp;
int main() {
fastio; local();
cin >> n >> s; s = '#' + s;
state[0] = state[1] = state[2] = 0;
int res = 0;
mp[state] = 0;
for(int i = 1; i <= n; i++) {
if(s[i] == 'J') state[0]--, state[1]++;
if(s[i] == 'O') state[1]--, state[2]++;
if(s[i] == 'I') state[2]--, state[0]++;
if(mp.find(state) != mp.end()) {
maxi(res, i - mp[state]);
}
else mp[state] = i;
}
cout << res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
