이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end();
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
vector<int> V[N];
vector<int> pos[N], neg[N];
int v[N];
ll count_swaps(vector<int> s) {
int n = s.size() >> 1;
for(int i = 0; i < n + n; i++){
if(s[i] > 0)
pos[abs(s[i])].pb(i);
else
neg[abs(s[i])].pb(i);
}
ll res = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j < (int) pos[i].size(); j++){
v[pos[i][j]] = v[neg[i][j]] = min(pos[i][j], neg[i][j]);
if(v[pos[i][j]] == pos[i][j])
res ++;
}
}
for(int i = 1; i < n + n; i++)
for(int j = 0; j < i; j++)
res += (v[j] > v[i]);
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... |