# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1047250 | vjudge1 | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 348 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;
#define ll long long int
#define pb push_back
long long count_swaps(std::vector<int> s) {
int n = s.size() + 5;
vector<deque<int>> pos(n + n);
ll ans = 0;
for(int i = 0; i < s.size(); ++i){
if(s[i] < 0){
if(pos[-s[i] + n].empty()){
pos[-s[i]].pb(i);
}else{
ans += i - pos[-s[i] + n].front();
pos[-s[i] + n].pop_front();
}
}else{
if(pos[s[i]].empty()){
pos[s[i] + n].pb(i);
}else{
ans += i - 1 - pos[s[i]].front();
pos[s[i]].pop_front();
}
}
// cout << 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... |