# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
156109 | 2019-10-03T13:12:30 Z | karma | JOIOJI (JOI14_joioji) | C++14 | 45 ms | 6216 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FileName "test" #define ll long long #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ord_set; typedef pair<int, int> pii; const int N = int(1e3) + 2; int n, curi, curj, curo, res = 0; pii cur; string s; map<pii, int> mmap; void Enter() { cin >> n >> s; curi = curj = curo = 0; cur = mp(0, 0); mmap[cur] = -1; for(int i = 0; i < n; ++i) { if(s[i] == 'O') ++curo; else if(s[i] == 'J') ++curj; else ++curi; cur = mp(curo - curi, curj - curo); if(mmap.count(cur)) { res = max(res, i - mmap[cur]); //cout << mmap[cur] << ' ' << i << '\n'; } else mmap[cur] = i; } cout << res; } void Solve() { } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(FileName".inp", "r")) { freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); } Enter(), Solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 296 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 504 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 504 KB | Output is correct |
2 | Correct | 8 ms | 912 KB | Output is correct |
3 | Correct | 13 ms | 1400 KB | Output is correct |
4 | Correct | 24 ms | 2172 KB | Output is correct |
5 | Correct | 36 ms | 3332 KB | Output is correct |
6 | Correct | 44 ms | 3500 KB | Output is correct |
7 | Correct | 45 ms | 3956 KB | Output is correct |
8 | Correct | 43 ms | 3328 KB | Output is correct |
9 | Correct | 45 ms | 3588 KB | Output is correct |
10 | Correct | 44 ms | 3332 KB | Output is correct |
11 | Correct | 40 ms | 5124 KB | Output is correct |
12 | Correct | 25 ms | 2180 KB | Output is correct |
13 | Correct | 25 ms | 1412 KB | Output is correct |
14 | Correct | 39 ms | 6216 KB | Output is correct |
15 | Correct | 29 ms | 1156 KB | Output is correct |