# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294918 | theStaticMind | 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 <bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long calculate(vector<int>& A, vector<int>& B){
long long ret = 0;
for(int i = 0; i < A.size(); i++){
ret += abs(A[i] - B[i]) - (A[i] < B[i]);
}
return ret;
}
long long count_swaps(std::vector<int> s) {
int n = s.size();
vector<int> A[n + 1], B[n + 1];
for(int i = 0; i < n; i++){
if(s[i] < 0) A[-s[i]].push_back(i);
else B[s[i]].push_back(i);
}
long long cnt = 0;
for(int i = 0; i <= n; i++){
cnt += calculate(A[i], B[i]);
}
return cnt;
}
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... |