# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145625 | chubyxdxd | Arranging Shoes (IOI19_shoes) | C++14 | 1084 ms | 3320 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"
#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;
for(int i=0;i<s.size();i++){
/* for(int j=0;j<s.size();j++){
cout<<s[j]<<" ";
}
cout<<endl;*/
if(i==0){
for(int j=i;j<s.size();j++){
if(s[j]<0){
h=j;
c+=abs(i-j);
break;
}
}
if(h==i){
continue;
}
for(int j=h;j>i;j--){
aux=s[j-1];
s[j-1]=s[j];
s[j]=aux;
}
continue;
}
if(i%2==0){
for(int j=i;j<s.size();j++){
if(s[j]<0){
h=j;
c+=abs(i-j);
break;
}
}
if(h==i){
continue;
}
for(int j=h;j>i;j--){
aux=s[j-1];
s[j-1]=s[j];
s[j]=aux;
}
}
else{
ll k=s[i-1]*-1;
for(int j=i;j<s.size();j++){
if(s[j]==k){
h=j;
c+=abs(i-j);
break;
}
}
if(h==i){
continue;
}
for(int j=h;j>i;j--){
aux=s[j-1];
s[j-1]=s[j];
s[j]=aux;
}
}
}
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... |