Submission #1031926

# Submission time Handle Problem Language Result Execution time Memory
1031926 2024-07-23T08:44:46 Z 정민찬(#10962) Monochrome Points (JOI20_monochrome) C++17
4 / 100
2000 ms 508 KB
#include <bits/stdc++.h>

using namespace std;

bool inter(int s1, int e1, int s2, int e2) {
    if (s1 > e1) swap(s1, e1);
    if (s2 > e2) swap(s2, e2);
    if (s1 > s2) swap(s1, s2), swap(e1, e2);
    return s2 < e1 && e1 < e2;
}

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> b, w;
    for (int i=0; i<2*n; i++) {
        if (s[i] == 'B') b.push_back(i);
        else w.push_back(i);
    }
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    int ans = 0;
    do {
        int cnt = 0;
        for (int i=0; i<n; i++) {
            for (int j=i+1; j<n; j++) {
                if (inter(b[i], w[perm[i]], b[j], w[perm[j]]))
                    cnt ++;
            }
        }
        ans = max(ans, cnt);
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 456 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 456 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Execution timed out 2062 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 456 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Execution timed out 2062 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 456 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Execution timed out 2062 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -