답안 #156108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156108 2019-10-03T13:05:59 Z karma JOIOJI (JOI14_joioji) C++14
95 / 100
50 ms 6232 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] = 0;
     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]);
        } 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

joioji.cpp: In function 'int main()':
joioji.cpp:48:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
        freopen(FileName".inp", "r", stdin);
        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
joioji.cpp:49:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
        freopen(FileName".out", "w", stdout);
        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 508 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 424 KB Output is correct
7 Correct 3 ms 380 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 8 ms 1016 KB Output is correct
3 Correct 13 ms 1528 KB Output is correct
4 Correct 24 ms 2296 KB Output is correct
5 Correct 36 ms 3460 KB Output is correct
6 Correct 45 ms 3716 KB Output is correct
7 Correct 46 ms 4100 KB Output is correct
8 Correct 46 ms 3588 KB Output is correct
9 Correct 50 ms 3848 KB Output is correct
10 Correct 48 ms 3588 KB Output is correct
11 Correct 43 ms 5380 KB Output is correct
12 Correct 27 ms 2308 KB Output is correct
13 Correct 26 ms 1672 KB Output is correct
14 Correct 38 ms 6232 KB Output is correct
15 Correct 29 ms 1280 KB Output is correct