# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143899 | tincamatei | Arranging Shoes (IOI19_shoes) | C++14 | 2 ms | 380 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 <vector>
#include <cstdlib>
using namespace std;
long long count_swaps(std::vector<int> s) {
int N = s.size() / 2;
vector<vector<int> > pozLeft(N), pozRight(N);
for(int i = 0; i < 2 * N; ++i)
if(s[i] < 0)
pozLeft[-s[i] - 1].push_back(i);
else
pozRight[s[i] - 1].push_back(i);
long long rez = 0LL;
for(int i = 0; i < N; ++i) {
for(int j = 0; j < pozLeft[i].size(); ++j) {
rez = rez + abs(pozLeft[i][j] - pozRight[i][j]) - 1;
if(pozLeft[i][j] > pozRight[i][j])
++rez;
}
}
return rez;
}
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... |