# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143127 | legend | Arranging Shoes (IOI19_shoes) | C++17 | 1082 ms | 15964 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;
long long count_swaps(std::vector<int> s) {
set<pair<int,int> > ms;
map<int,int> pos;
for(int i = 0;i<s.size();i++){
if(s[i]<0) ms.insert({i,s[i]});
pos[s[i]] = i;
}
int ps = 0;
long long ans = 0;
while(ps<s.size()){
pair<int,int> x;
for(int i = ps;;i++){
if(s[i]<0){
x = {i,s[i]};
break;
}
ans++;
}
for(int i = ps;i<x.first;i++){
int u = s[i];
pos[u]++;
}
for(int i = x.first;i>ps;i--){
swap(s[i],s[i-1]);
}
for(int i = ps+1;;i++){
if(s[i] == -x.second){
ans+=(i-ps-1);
for(int j = i;j>ps+1;j--) swap(s[j],s[j-1]);
break;
}
}
// cout<<ans<<endl;
ps+=2;
}
return ans;
return 1;
}
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... |