# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
39681 | 14kg | JOIOJI (JOI14_joioji) | C++11 | 33 ms | 24340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <map>
#define P 66667
#define N 200005
#define INF 999999999
#define Abs(x) (x>0?x:-(x))
#define max2(x,y) (x>y?x:y)
using namespace std;
int n;
char in[N];
map<int, int> M[N * 2];
int Find(int x, int y, int w) {
if (x == 0 && y == 0) return 0;
int res = M[x + n][y];
if (!res) M[x + n][y] = w;
return res ? res : INF;
}
int main() {
int x = 0, y = 0, w, out = 0;
scanf("%d %s", &n, in + 1);
for (int i = 1; i <= n; i++) {
if (in[i] == 'J') x++, y++;
else if (in[i] == 'O') x--;
else y--;
w = Find(x, y, i), out = max2(out, i - w);
} printf("%d", out);
}
컴파일 시 표준 에러 (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... |