Submission #628383

# Submission time Handle Problem Language Result Execution time Memory
628383 2022-08-13T11:05:34 Z MohamedFaresNebili Monochrome Points (JOI20_monochrome) C++14
0 / 100
1 ms 212 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[305];
            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; int res = 0;
                for(int l = 0; l < N; l++) P[l] = l;
                for(int l = 0; l < N / 2; l++) {
                    if(P[l] != l) continue;
                    int i = l + N / 2, j = l + N / 2;
                    for(; i < N; i++) {
                        if(S[l] == S[i] || P[i] != i)
                            continue;
                        break;
                    }
                    for(; j > l; j--) {
                        if(S[l] == S[j] || P[j] != j)
                            continue;
                        break;
                    }
                    int A = 0, B = 0;
                    for(int k = min(l, i); k <= max(l, i); k++)
                        A += (P[k] < min(i, l) || P[k] > max(i, l));
                    for(int k = min(l, j); k <= max(l, j); k++)
                        B += (P[k] < min(j, l) || P[k] > max(j, l));
                    if(i != N && A >= B) {
                        res += A; P[l] = i, P[i] = l;
                        continue;
                    }
                    res += B; P[l] = j, P[j] = l;
                }
                cout << res << "\n";
                return 0;
            }




# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -