답안 #516349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516349 2022-01-21T07:46:39 Z qwerasdfzxcl Monochrome Points (JOI20_monochrome) C++14
25 / 100
2000 ms 320 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const ll INF = 1e18;
char a[400400];
int B[200200], W[200200];
vector<pair<int, int>> E;

int calc(){
    for (auto &p:E) if (p.first > p.second) swap(p.first, p.second);
    sort(E.begin(), E.end());

    int ret = 0;
    for (int i=0;i<(int)E.size();i++){
        //printf("%d %d\n", E[i].first, E[i].second);
        for (int j=i+1;j<(int)E.size();j++) if (E[j].first < E[i].second && E[i].second < E[j].second) ret++;
    }
    //printf("\n");
    return ret;
}

int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", a+1);
    n *= 2;

    int cb = 0, cw = 0;
    for (int i=1;i<=n;i++){
        if (a[i]=='B') B[++cb] = i;
        else W[++cw] = i;
    }

    int ans = 0;
    for (int z=1;z<=n/2;z++){
        E.clear();
        int pt = z;
        for (int i=1;i<=n/2;i++){
            E.emplace_back(B[i], W[pt]);
            pt++;
            if (pt>n/2) pt -= n/2;
        }

        ans = max(ans, calc());
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

monochrome.cpp: In function 'int main()':
monochrome.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
monochrome.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%s", a+1);
      |     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 13 ms 204 KB Output is correct
15 Correct 20 ms 300 KB Output is correct
16 Correct 13 ms 296 KB Output is correct
17 Correct 13 ms 296 KB Output is correct
18 Correct 10 ms 316 KB Output is correct
19 Correct 11 ms 320 KB Output is correct
20 Correct 11 ms 204 KB Output is correct
21 Correct 11 ms 320 KB Output is correct
22 Correct 12 ms 204 KB Output is correct
23 Correct 5 ms 300 KB Output is correct
24 Correct 10 ms 316 KB Output is correct
25 Correct 10 ms 320 KB Output is correct
26 Correct 11 ms 296 KB Output is correct
27 Correct 12 ms 204 KB Output is correct
28 Correct 12 ms 296 KB Output is correct
29 Correct 9 ms 204 KB Output is correct
30 Correct 9 ms 204 KB Output is correct
31 Correct 13 ms 204 KB Output is correct
32 Correct 14 ms 204 KB Output is correct
33 Correct 14 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 13 ms 204 KB Output is correct
15 Correct 20 ms 300 KB Output is correct
16 Correct 13 ms 296 KB Output is correct
17 Correct 13 ms 296 KB Output is correct
18 Correct 10 ms 316 KB Output is correct
19 Correct 11 ms 320 KB Output is correct
20 Correct 11 ms 204 KB Output is correct
21 Correct 11 ms 320 KB Output is correct
22 Correct 12 ms 204 KB Output is correct
23 Correct 5 ms 300 KB Output is correct
24 Correct 10 ms 316 KB Output is correct
25 Correct 10 ms 320 KB Output is correct
26 Correct 11 ms 296 KB Output is correct
27 Correct 12 ms 204 KB Output is correct
28 Correct 12 ms 296 KB Output is correct
29 Correct 9 ms 204 KB Output is correct
30 Correct 9 ms 204 KB Output is correct
31 Correct 13 ms 204 KB Output is correct
32 Correct 14 ms 204 KB Output is correct
33 Correct 14 ms 320 KB Output is correct
34 Execution timed out 2065 ms 292 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 13 ms 204 KB Output is correct
15 Correct 20 ms 300 KB Output is correct
16 Correct 13 ms 296 KB Output is correct
17 Correct 13 ms 296 KB Output is correct
18 Correct 10 ms 316 KB Output is correct
19 Correct 11 ms 320 KB Output is correct
20 Correct 11 ms 204 KB Output is correct
21 Correct 11 ms 320 KB Output is correct
22 Correct 12 ms 204 KB Output is correct
23 Correct 5 ms 300 KB Output is correct
24 Correct 10 ms 316 KB Output is correct
25 Correct 10 ms 320 KB Output is correct
26 Correct 11 ms 296 KB Output is correct
27 Correct 12 ms 204 KB Output is correct
28 Correct 12 ms 296 KB Output is correct
29 Correct 9 ms 204 KB Output is correct
30 Correct 9 ms 204 KB Output is correct
31 Correct 13 ms 204 KB Output is correct
32 Correct 14 ms 204 KB Output is correct
33 Correct 14 ms 320 KB Output is correct
34 Execution timed out 2065 ms 292 KB Time limit exceeded
35 Halted 0 ms 0 KB -