# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537305 | ERH | Arranging Shoes (IOI19_shoes) | C++14 | 1085 ms | 20368 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 <iostream>
#include <vector>
using namespace std;
vector<int> lista[100000][2];
int temp[100000];
long long count_swaps(vector<int> v){
long long int total=0;
for(int i=0; i<v.size(); ++i){
int a=v[i];
if(a<0){
a=-a;
if(!lista[a][0].empty()){
int temp1=i, temp2=lista[a][0].front();
for(int j=0; j<i; ++j){
temp1+=temp[j];
}
for(int j=0; j<lista[a][0].front(); ++j){
temp2+=temp[j];
}
total+=temp1-temp2;
temp[lista[a][0].front()]++;
temp[i]--;
lista[a][0].erase(lista[a][0].begin());
} else {
lista[a][1].push_back(i);
}
} else {
if(!lista[a][1].empty()){
int temp1=i, temp2=lista[a][1].front();
for(int j=0; j<i; ++j){
temp1+=temp[j];
}
for(int j=0; j<lista[a][1].front(); ++j){
temp2+=temp[j];
}
total+=temp1-temp2;
temp[lista[a][1].front()]++;
total--;
temp[i]--;
lista[a][1].erase(lista[a][1].begin());
} else {
lista[a][0].push_back(i);
}
}
}
return total;
}
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... |