# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201541 | s_avila_g | Arranging Shoes (IOI19_shoes) | C++14 | 5 ms | 376 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 <bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long count_swaps(std::vector<int> s) {
bool der = false;
int ans = 0;
for(int i = 0 ; i < s.size(); i++){
der = false;
if(s[i] > 0) der = true;
int pos = s.size() + 1;
for(int j = i+1; j < s.size(); j++){
if(abs(s[i] == abs(s[j]))){
pos = j;
s.erase(s.begin() + j);
break;
}
}
if(pos == i + 1 && !der){
i += 2;
continue;
}
if(pos == s.size() + 1) continue;
if(der) ans += abs(i - pos);
else ans += abs(i - pos) - 1;
}
return ans;
}
Compilation message (stderr)
# | 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... |