이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int>v) {
int fixed = -1, n = v.size();
long long ans = 0;
while(fixed < n-1) {
int fix = -v[fixed+1];
int pos = fixed+2;
while(pos < n && v[pos] != fix) pos++;
for(int i = pos-1 ; i > fixed+1 ; i--) ans++,swap(v[i],v[i+1]);
if(fix < 0) {
ans++;
swap(v[fixed+1],v[fixed+2]);
}
fixed+=2;
}
return ans;
}
/*
signed main() {
int n; cin>>n;
vector<int>v(n);
for(auto &z : v)
cin >> z;
cout << count_swaps(v);
}
*/
# | 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... |