# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890588 | svaz | Arranging Shoes (IOI19_shoes) | C++14 | 1091 ms | 3056 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<iostream>
#include<vector>
using namespace std;
long long count_swaps(std::vector<int> S){
long long sw=0;
vector<int> pos_der, pos_izq;
for(int i=0;i<S.size()-1;i+=2){
//if(!(S[i]<0 && S[i+1]>0 && abs(S[i])==abs(S[i+1]))){
if(S[i]>0)pos_der.push_back(i);
else pos_izq.push_back(i);
if(S[i+1]>0)pos_der.push_back(i+1);
else pos_izq.push_back(i+1);
//}
}
for(int i=0;i<pos_izq.size();i++){
sw+=abs(pos_der[i]-pos_izq[i]);
if(pos_izq[i]<pos_der[i])sw--;
for(int j=i+1;j<pos_izq.size();j++){
if(pos_der[i]>pos_izq[j])pos_izq[j]++;
else break;
}
for(int j=i+1;j<pos_der.size();j++){
if(pos_izq[i]>pos_der[j])pos_der[j]++;
else break;
}
/* for(int i=0;i<pos_der.size();i++){
cout<<pos_der[i]<<" ";
}
cout<<endl;
for(int i=0;i<pos_der.size();i++){
cout<<pos_izq[i]<<" ";
}
cout<<endl;*/
}
return sw;
}
/*int main(){
cinl.tie(NULL);
int n,zap;
cin>>n;
vector<int>zapatos;
for(int i=0;i<(n*2);i++){
cin>>zap;
zapatos.push_back(zap);
}
cout<<count_swaps(zapatos)<<"\n";
ios_base::sync_with_stdio(false);
return 0;
}*/
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... |