| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 694855 | allin27x | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 0 KiB |
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 <iostream>
#include <vector>
using namespace std;
long long count_swaps(vector<int> S){
long long res = 0;
int n = S.size();
vector<int> s(n,0);
vector<bool> ac(n,1);
for (int i=0; i<n; i++){
if (!ac[i]) continue;
for (int j=i+1; j<n; j++){
if (!ac[j] || S[j])!=-S[i]) continue;
ac[j] = 0;
ac[i] = 0;
if (S[i]<0) res+=j-i-1; else res+=j-i; break;
}
}
return res;
}
