Submission #683808

# Submission time Handle Problem Language Result Execution time Memory
683808 2023-01-19T11:45:59 Z Fysty Monochrome Points (JOI20_monochrome) C++17
35 / 100
162 ms 5604 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MottoHayaku ios::sync_with_stdio(false);cin.tie(0);
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define F first
#define S second
#define pb push_back

const int N=4005;
struct BIT
{
    int a[N];
    void init()
    {
        rep1(i,N-1) a[i]=0;
    }
    void upd(int x,int val)
    {
        for(;x<N;x+=x&-x) a[x]+=val;
    }
    int qry(int x)
    {
        int ret=0;
        for(;x;x-=x&-x) ret+=a[x];
        return ret;
    }
} bit;
int to[N];
signed main()
{
    MottoHayaku
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> a,b;
    rep(i,n*2)
    {
        if(s[i]=='B') a.pb(i+1);
        else b.pb(i+1);
    }
    int ans=0;
    rep(i,n)
    {
        rep(j,n)
        {
            to[a[j]]=b[(j+i)%n];
            to[b[(j+i)%n]]=a[j];
        }
        bit.init();
        int tot=0;
        rep1(j,n*2)
        {
            if(to[j]<j) bit.upd(j,-1);
            else
            {
                tot+=bit.qry(to[j]);
                bit.upd(to[j],1);
            }
        }
        ans=max(ans,tot);
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 6 ms 352 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 324 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 3 ms 432 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 6 ms 352 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 324 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 3 ms 432 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 156 ms 364 KB Output is correct
35 Correct 162 ms 364 KB Output is correct
36 Correct 144 ms 360 KB Output is correct
37 Correct 137 ms 364 KB Output is correct
38 Correct 85 ms 460 KB Output is correct
39 Correct 95 ms 364 KB Output is correct
40 Correct 87 ms 360 KB Output is correct
41 Correct 89 ms 328 KB Output is correct
42 Correct 142 ms 364 KB Output is correct
43 Correct 113 ms 376 KB Output is correct
44 Correct 111 ms 340 KB Output is correct
45 Correct 100 ms 360 KB Output is correct
46 Correct 108 ms 360 KB Output is correct
47 Correct 109 ms 340 KB Output is correct
48 Correct 99 ms 372 KB Output is correct
49 Correct 83 ms 360 KB Output is correct
50 Correct 98 ms 340 KB Output is correct
51 Correct 97 ms 360 KB Output is correct
52 Correct 119 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 6 ms 352 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 324 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 3 ms 432 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 156 ms 364 KB Output is correct
35 Correct 162 ms 364 KB Output is correct
36 Correct 144 ms 360 KB Output is correct
37 Correct 137 ms 364 KB Output is correct
38 Correct 85 ms 460 KB Output is correct
39 Correct 95 ms 364 KB Output is correct
40 Correct 87 ms 360 KB Output is correct
41 Correct 89 ms 328 KB Output is correct
42 Correct 142 ms 364 KB Output is correct
43 Correct 113 ms 376 KB Output is correct
44 Correct 111 ms 340 KB Output is correct
45 Correct 100 ms 360 KB Output is correct
46 Correct 108 ms 360 KB Output is correct
47 Correct 109 ms 340 KB Output is correct
48 Correct 99 ms 372 KB Output is correct
49 Correct 83 ms 360 KB Output is correct
50 Correct 98 ms 340 KB Output is correct
51 Correct 97 ms 360 KB Output is correct
52 Correct 119 ms 340 KB Output is correct
53 Runtime error 7 ms 5604 KB Execution killed with signal 11
54 Halted 0 ms 0 KB -