이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#ifdef ONPC
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
using namespace std;
//namespace pbds = __gnu_pbds;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); }
const string fileio = "";
constexpr int tests = 1, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7;
long long count_swaps(std::vector<int> s) {
int n = s.size();
vector<int> pr(2*n,-1);
for (int i = 0; i < n; i++) {
if (~pr[i]) continue;
for (int j = i+1; j < n; j++) {
if (s[i] == s[j]) {
pr[i] = j;
pr[j] = i;
break;
}
}
assert(~pr[i]);
}
ll res = 0;
for (int i = 0; i < n; i++) {
if (pr[i] < i) continue;
int cnt= 0;
for (int j = i+1; j <= pr[i]-1; j++) {
if (i < pr[j] && pr[j] < pr[i]) continue;
cnt++;
}
res += cnt;
}
return res;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |