# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144707 | chubyxdxd | Arranging Shoes (IOI19_shoes) | C++14 | 1072 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long count_swaps(std::vector<int> s) {
ll tam=s.size();
if(tam/2==1){
if(s[0]<0){
return 0;
}
else{
return 1;
}
}
ll hi=0;
ll h,c=0,f,aux;
while(hi<tam){
for(int i=hi;i<tam;i++){
if(s[i]<0){
h=i;
f=s[i];
c+=abs(hi-i);
break;
}
}
for(int i=h;i>hi;i--){
aux=s[i-1];
s[i-1]=s[i];
s[i]=aux;
}
hi++;
/*cout<<c<<" - "<<hi<<endl;
for(int i=0;i<tam;i++){
cout<<s[i]<<" ";
}
cout<<endl;*/
for(int i=hi;i<tam;i++){
if((s[i]*-1)==f){
h=i;
c+=abs(hi-i);
break;
}
}
for(int i=h;i>hi;i--){
aux=s[i-1];
s[i-1]=s[i];
s[i]=aux;
}
hi++;
/*cout<<c<<" - "<<hi<<endl;
for(int i=0;i<tam;i++){
cout<<s[i]<<" ";
}
cout<<endl;*/
}
return c;
}
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... |