Submission #516350

# Submission time Handle Problem Language Result Execution time Memory
516350 2022-01-21T07:47:16 Z qwerasdfzxcl Monochrome Points (JOI20_monochrome) C++14
0 / 100
1 ms 204 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);

    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:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
monochrome.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%s", a+1);
      |     ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -