# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314556 | baibhav26062008 | Arranging Shoes (IOI19_shoes) | C++14 | 1 ms | 256 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;
long long count_swaps(std::vector<int> s) {
int n = s.size()/2;
if (n == 1) {
if (s[0] < s[1]) {
return 0;
} else {
return 1;
}
}
long long ans=0;
for (int i = 0; i < n; i++) {
ans+=i;
}
bool all_equal = true;
for (int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if (i != j) {
if (abs(s[i]) != abs(s[j])) {
all_equal = false;
break;
}
}
}
if (all_equal == false) break;
}
if (all_equal) {
ans = 0;
for (int i = 0;i < s.size(); i++) {
if (abs(s[i])) {
for (int j = i;j < s.size(); j++) {
if (abs(s[i]) == abs(s[j])) {
ans += abs(j - i);
}
if (s[i] > s[j]) {
ans++;
}
}
}
}
}
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... |