Submission #369805

# Submission time Handle Problem Language Result Execution time Memory
369805 2021-02-22T12:49:38 Z mathking1021 JOIOJI (JOI14_joioji) C++17
95 / 100
77 ms 11896 KB
#include <iostream>
#include <cstdio>
#include <map>
#define PLL pair<ll, ll>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n;
string s;
ll a, b, ans;

map<PLL, ll> ma1, ma2;

int main()
{
    cin>>n>>s;
    ma1[make_pair(0, 0)] = ma2[make_pair(0, 0)] = 1;
    for(ll i = 0; i < n; i++)
    {
        if(s[i] == 'J')
        {
            a++;
        }
        else if(s[i] == 'O')
        {
            a--, b++;
        }
        else
        {
            b--;
        }
        if(!ma1.count(make_pair(a, b))) ma1[make_pair(a, b)] = i + 1;
        ma2[make_pair(a, b)] = i + 1;
    }
    for(auto i:ma1)
    {
        ll t1 = i.F.F;
        ll t2 = i.F.S;
        ll t3 = i.S;
        ans = max(ans, ma2[make_pair(t1, t2)] - t3);
    }
    printf("%lld\n", ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 268 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 748 KB Output is correct
2 Correct 10 ms 1516 KB Output is correct
3 Correct 18 ms 2540 KB Output is correct
4 Correct 35 ms 4076 KB Output is correct
5 Correct 55 ms 6396 KB Output is correct
6 Correct 64 ms 6520 KB Output is correct
7 Correct 70 ms 7544 KB Output is correct
8 Correct 65 ms 6392 KB Output is correct
9 Correct 69 ms 6904 KB Output is correct
10 Correct 77 ms 6372 KB Output is correct
11 Correct 61 ms 9848 KB Output is correct
12 Correct 47 ms 3960 KB Output is correct
13 Correct 35 ms 2552 KB Output is correct
14 Correct 68 ms 11896 KB Output is correct
15 Correct 25 ms 2044 KB Output is correct