# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1040916 | idas | Arranging Shoes (IOI19_shoes) | C++17 | 1100 ms | 6720 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 <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N=2e5+10;
int n, cn[N], pos[N];
vi p_pos, n_pos[N];
long long count_swaps(vector<int> s) {
n=s.size();
ll ans=0;
for(int i=n-1; i>=0; i--){
int src;
if(i&1){
int in;
for(int j=i; j>=0; j--){
if(s[j]>0){
src=s[j];
in=j;
break;
}
}
for(int j=in+1; j<=i; j++){
swap(s[j-1], s[j]);
ans++;
}
}
else{
int in;
for(int j=i; j>=0; j--){
if(s[j]==-src){
in=j;
break;
}
}
for(int j=in+1; j<=i; j++){
swap(s[j-1], s[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... |