답안 #536359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536359 2022-03-13T04:48:45 Z Monarchuwu Monochrome Points (JOI20_monochrome) C++17
4 / 100
5 ms 340 KB
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<numeric>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;

const int N = 25 + 8, inf = 0x80808080;
int n, n2;
char s[N << 1];
vector<int> B, W;

bool inside(int l, int r, int p) {
    return (p - l) * (ll)(p - r) < 0;
}
int p[N];
int calc() {
    // B[i], W[p[i]]
    int ans(0);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < i; ++j)
            ans += inside(B[i], W[p[i]], B[j]) ^ inside(B[i], W[p[i]], W[p[j]]);
    return ans;
}

int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> (s + 1);
    n2 = n << 1;
    for (int i = 1; i <= n2; ++i) {
        if (s[i] == 'B')
            B.push_back(i);
        else W.push_back(i);
    }

    iota(p, p + n, 0);
    int ans(0);
    do {
        ans = max(ans, calc());
    } while (next_permutation(p, p + n));

    cout << ans << '\n';
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 5 ms 320 KB Output is correct
11 Correct 4 ms 212 KB Output is correct
12 Correct 4 ms 320 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 5 ms 320 KB Output is correct
11 Correct 4 ms 212 KB Output is correct
12 Correct 4 ms 320 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 5 ms 320 KB Output is correct
11 Correct 4 ms 212 KB Output is correct
12 Correct 4 ms 320 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 5 ms 320 KB Output is correct
11 Correct 4 ms 212 KB Output is correct
12 Correct 4 ms 320 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -