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;
typedef long long ll;
map<ll, queue<int>> shoesList;
ll count_swaps(vector<int> s) {
ll sum = 0;
for (unsigned int i = 0; i < s.size(); i++) {
int pos = i+1;
if (s[i] > 0) {pos--;}
cerr << "I: " << i << " SHOE: " << s[i] << endl;
cerr << "POS OF INVERSE:" << shoesList[-s[i]].front() << endl;
if (shoesList[-s[i]].size() == 0) {
shoesList[s[i]].push(pos);
} else {
sum += (i - shoesList[-s[i]].front());
shoesList[-s[i]].pop();
}
}
return sum;
}
# | 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... |