This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++) {
for(int i = N / 2; i < N; i++) {
if(S[l] == S[i] || P[i] != i) continue;
for(int j = l + 1; j < i; j++) {
res += (P[j] > i || P[j] < l);
}
P[l] = i, P[i] = l; break;
}
}
cout << res << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |