답안 #298941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298941 2020-09-14T10:55:10 Z toloraia Monochrome Points (JOI20_monochrome) C++14
35 / 100
2000 ms 6656 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;

int n;
int F[N];

void upd (int x){
    for (; x <= n; x += x&-x)
        F[x]++;
}

int dat (int x){
    int ans = 0;
    for (; x > 0; x &= x-1)
        ans += F[x];
    return ans;
}

int ANS, ans, a[N];
string S;
vector < int > V[2];


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> S;
    S = S + S;
    for (int st = 0; st < n; st++){
        for (int i = 1; i <= n; i++){
            char ch=S[i+st-1];
            if (ch == 'B')
                a[i] = 1;
            else
                a[i] = 0;
        }
        for (int i = 1; i <= n; i++){
            char ch = S[i+st+n-1];
            if (ch == 'W')
                V[1].pb (i);
            else
                V[0].pb (i);
        }
        for (int i = n; i >= 1; i--){
            int x = V[a[i]].back();
            V[a[i]].pop_back ();
            ans += dat (n) - dat (x);
            upd (x);
        }
        ANS = max (ans, ANS);
        ans = 0;
        for (int i = 1; i <= n; i++)
            F[i] = 0;
        V[0].clear();
        V[1].clear();
    }
    cout << ANS << endl;
}

Compilation message

monochrome.cpp:19:1: warning: "/*" within comment [-Wcomment]
   19 | /*
      |  
monochrome.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 3 ms 416 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 416 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 3 ms 416 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 416 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 142 ms 384 KB Output is correct
35 Correct 137 ms 384 KB Output is correct
36 Correct 132 ms 384 KB Output is correct
37 Correct 125 ms 504 KB Output is correct
38 Correct 90 ms 384 KB Output is correct
39 Correct 97 ms 484 KB Output is correct
40 Correct 84 ms 384 KB Output is correct
41 Correct 85 ms 384 KB Output is correct
42 Correct 133 ms 384 KB Output is correct
43 Correct 123 ms 384 KB Output is correct
44 Correct 109 ms 384 KB Output is correct
45 Correct 106 ms 512 KB Output is correct
46 Correct 108 ms 384 KB Output is correct
47 Correct 110 ms 384 KB Output is correct
48 Correct 107 ms 384 KB Output is correct
49 Correct 93 ms 384 KB Output is correct
50 Correct 100 ms 492 KB Output is correct
51 Correct 99 ms 504 KB Output is correct
52 Correct 98 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 3 ms 416 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 416 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 142 ms 384 KB Output is correct
35 Correct 137 ms 384 KB Output is correct
36 Correct 132 ms 384 KB Output is correct
37 Correct 125 ms 504 KB Output is correct
38 Correct 90 ms 384 KB Output is correct
39 Correct 97 ms 484 KB Output is correct
40 Correct 84 ms 384 KB Output is correct
41 Correct 85 ms 384 KB Output is correct
42 Correct 133 ms 384 KB Output is correct
43 Correct 123 ms 384 KB Output is correct
44 Correct 109 ms 384 KB Output is correct
45 Correct 106 ms 512 KB Output is correct
46 Correct 108 ms 384 KB Output is correct
47 Correct 110 ms 384 KB Output is correct
48 Correct 107 ms 384 KB Output is correct
49 Correct 93 ms 384 KB Output is correct
50 Correct 100 ms 492 KB Output is correct
51 Correct 99 ms 504 KB Output is correct
52 Correct 98 ms 464 KB Output is correct
53 Execution timed out 2037 ms 6656 KB Time limit exceeded
54 Halted 0 ms 0 KB -