Submission #628343

# Submission time Handle Problem Language Result Execution time Memory
628343 2022-08-13T10:38:02 Z MohamedFaresNebili Monochrome Points (JOI20_monochrome) C++14
4 / 100
2000 ms 340 KB
#include <bits/stdc++.h>

            using namespace std;

            using ll = long long;
            using ld = long double;
            using pi = pair<pair<int, int>, pair<int, int>>;

            #define ff first
            #define ss second
            #define pb push_back
            #define all(x) (x).begin(), (x).end()
            #define lb lower_bound
            #define int ll

            int N, P[50];
            vector<int> A, B;
            string S;

            int32_t main() {
                ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                cin >> N >> S; N *= 2;
                for(int l = 0; l < N; l++) {
                    if(S[l] == 'B') A.push_back(l);
                    if(S[l] == 'W') B.push_back(l);
                }
                int res = 0;
                do{
                    for(int l = 0; l < N; l++) P[l] = l;
                    int ans = 0;
                    for(int i = 0; i < N / 2; i++) {
                        int U = A[i], V = B[i];
                        for(int j = min(U, V); j <= max(U, V); j++) {
                            ans += (P[j] < min(U, V) || P[j] > max(U, V));
                        }
                        P[U] = V, P[V] = U;
                    }
                    res = max(res, ans);
                } while(next_permutation(B.begin(), B.end()));
                cout << res << "\n";
                return 0;
            }

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 6 ms 324 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Correct 5 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 6 ms 324 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Correct 5 ms 212 KB Output is correct
14 Execution timed out 2066 ms 340 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 6 ms 324 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Correct 5 ms 212 KB Output is correct
14 Execution timed out 2066 ms 340 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 6 ms 324 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Correct 5 ms 212 KB Output is correct
14 Execution timed out 2066 ms 340 KB Time limit exceeded
15 Halted 0 ms 0 KB -