# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075509 | mindiyak | Arranging Shoes (IOI19_shoes) | C++14 | 93 ms | 135024 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 <deque>
#include <iostream>
#define ll long long
#define F first
#define S second
using namespace std;
long long count_swaps(std::vector<int> s) {
ll ans = 0;
ll cnt = 0;
vector<deque<pair<int,int>>> arr(2e5+10);
for(int i = 0;i<s.size();i++){
int left = 0;
if(s[i] < 0)left = 1;
// if(left)cerr << "left ";
// else cerr << "right ";
cerr << s[i] << " " << arr[-s[i]+1e5].size() << " ";
if(arr[-s[i]+1e5].size() > 0){
auto a = arr[-s[i]+1e5][0];
arr[-s[i]+1e5].pop_front();
cnt --;
// cerr << a.F << " " << a.S << " " << cnt << endl;
ans += i - a.F - (cnt - a.S);
if(left == 0)ans -= 1;
}else{
// cerr << s[i]+1e5 << " " << i << " " << cnt << endl;
arr[s[i]+1e5].push_back({i,cnt});
cnt ++;
}
}
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... |