# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
312795 | Basilhijaz | Arranging Shoes (IOI19_shoes) | C++17 | 1136 ms | 541936 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 pb push_back
vector<pair<int, int> > pairs;
long long count_swaps(vector<int> s) {
int n = s.size();
queue<int> left[2*n + 1];
queue<int> right[2*n + 1];
bool done[n];
memset(done, 0, sizeof(done));
/*for(int i = 0; i < n; i++){
if(s[i] < 0){
if(!right[abs(s[i])].empty()){
pairs.pb({right[abs(s[i])].top(), i});
right[abs(s[i])].pop();
}
else{
left[abs(s[i])].push(i);
}
}
else{
if(!left[s[i]].empty()){
pairs.pb({left[s[i]].top(), i});
left[s[i]].pop();
}
else{
right[s[i]].push(i);
}
}
}
/**/
for(int i = 0; i < n; i++){
if(!done[i]){
int serach = s[i]*-1;
int first = -1; int second = -1;
first = i;
for(int j = i + 1; j < n; j++){
if(s[j] == serach && !done[j]){
second = j;
done[j] = 1;
break;
}
}
pairs.pb({first, second});
}
}
int ans = 0;
for(int i = 0; i < pairs.size(); i++){
if(s[pairs[i].first] > 0){
ans++;
}
}
memset(done, 0, sizeof(done));
for(int i = 0; i < pairs.size(); i++){
done[pairs[i].second] = 1;
for(int j = pairs[i].first + 1; j < pairs[i].second; j++){
if(!done[j])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... |