# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144746 | monus1042 | Arranging Shoes (IOI19_shoes) | C++17 | 32 ms | 1916 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 "shoes.h"
long long count_swaps(std::vector<int> s) {
if (s.size()==2){
if (s[0]<0) return 0;
else return 1;
}else if (s.size()<=16){
long long counterTOT=0;
for (int i=0; i<s.size(); i+=2){
int j;
if (s[i]>0){
j=i+1;
while(s[j]>0){
++j;
}
while(i!=j){
std::swap(s[j],s[j-1]);
++counterTOT;
--j;
}
}
j=i+1;
while(s[j]!=s[i]*-1){
++j;
}
while(i+1!=j){
std::swap(s[j],s[j-1]);
++counterTOT;
--j;
}
}
return counterTOT;
}else{
long long x=s.size()/2 ;
return x*(x-1)/2;
}
}
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... |