답안 #612534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
612534 2022-07-29T17:00:54 Z okkuu JOIOJI (JOI14_joioji) C++17
100 / 100
39 ms 10428 KB
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
#include<bitset>
#include<cassert>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int dx[]={1,0,0,-1},dy[]={0,1,-1,0};
int main(){
	int n;
	string s;
	cin>>n>>s;
	map<pair<int,int>,vector<int>>mp;
	int x=0,y=0;
	mp[{x,y}].push_back(0);
	for(int i=0;i<n;i++){
		if(s[i]=='J')
			x++;
		if(s[i]=='O')
			y++;
		if(s[i]=='I')
			x--,y--;
		mp[{x,y}].push_back(i+1);
	}
	int ans=0;
	for(auto&e:mp)
		if(e.second.size()>=2)
			ans=max(ans,e.second.back()-e.second[0]);
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 6 ms 1364 KB Output is correct
3 Correct 11 ms 2260 KB Output is correct
4 Correct 23 ms 3796 KB Output is correct
5 Correct 32 ms 5848 KB Output is correct
6 Correct 37 ms 6236 KB Output is correct
7 Correct 38 ms 6968 KB Output is correct
8 Correct 34 ms 5980 KB Output is correct
9 Correct 35 ms 6524 KB Output is correct
10 Correct 39 ms 6100 KB Output is correct
11 Correct 37 ms 8668 KB Output is correct
12 Correct 25 ms 4140 KB Output is correct
13 Correct 22 ms 3112 KB Output is correct
14 Correct 39 ms 10428 KB Output is correct
15 Correct 17 ms 2632 KB Output is correct