# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889090 | Lincito_31 | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 348 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 x=0;
long long count_swaps(vector<int> s) {
vector<pair<int,int>> par_posi;
vector<pair<int,int>> par_nega;
for(int i=0;i<s.size();i++){
if(s[i]>0){
par_posi.push_back(make_pair(s[i],i));
}else{
par_nega.push_back(make_pair(s[i],i));
}
}
sort(par_posi.begin(),par_posi.end());
sort(par_nega.begin(),par_nega.end());
int parencontrado=0;
while(!s.empty()){
int ini=0,fin=par_posi.size()-1,mitad;
int temp=s[0];
if(temp<0){
mitad=(ini+fin)/2;
while(par_posi[mitad].first!=-temp){
if(par_posi[mitad].first>-temp){
fin=mitad-1;
}else{
ini=mitad+1;
}
}
x+=par_posi[mitad].second-1-parencontrado;
//s.erase(s.begin()+par_posi[mitad].second);
s.erase(s.begin());
par_posi.erase(par_posi.begin()+mitad);
//parencontrado++;
}else{
mitad=(ini+fin)/2;
while(par_nega[mitad].first!=-temp){
if(par_nega[mitad].first<-temp){
ini=mitad++;
}else{
fin=mitad--;
}
}
x+=par_nega[mitad].second-parencontrado;
//s.erase(s.begin()+par_nega[mitad].second);
s.erase(s.begin());
par_nega.erase(par_nega.begin()+mitad);
//parencontrado++;
}
}
return x;
}
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... |