# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499975 | uHyHn | Arranging Shoes (IOI19_shoes) | C++14 | 1062 ms | 3880 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 count_swaps(std::vector<int> s) {
vector <int> v;
v=s;
int n=s.size();
//cout << n << " ";
if (n/2 == 1){
if (v[0] < v[1]) return 0;
else return 1;
}
long long ans=0;
for (int i=0;i<n;i+=2){
if (v[i] > 0){
for (int j=i+1;j<n;j++){
if (-v[j] == v[i]){
for (int j1=j-1;j1>=i;j1--) swap(v[j1], v[j1+1]), ans++;
break;
}
}
}
else {
for (int j=i+1;j<n;j++){
if (-v[j] == v[i]){
for (int j1=j-1;j1>i;j1--) swap(v[j1], v[j1+1]), ans++;
break;
}
}
}
}
bool ok=1;
for (int i=0;i<n/2;i++){
if (v[(n/2)+i]+v[i] == 0 and v[i] < 0);
else{
ok=0;
break;
}
}
return ans;
}
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... |