# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034207 | nickolasarapidis | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 432 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
ll count_swaps(vector<int> S){
int N = S.size();
deque<int> A(N);
for(int i = 0; i < N; i++){
A[i] = S[i];
}
ll ans = 0;
while(N > 0){
int a = A.front();
if(a < 0 and A[1] == a + 2*a){
A.pop_front();
A.pop_front();
N -= 2;
continue;
}
if(a < 0){
for(int i = 0; i < N; i++){
if(A[i] == a + 2*a){
int b = i;
while(b != 1){
swap(A[b], A[b - 1]);
b--;
ans++;
}
}
break;
}
A.pop_front();
A.pop_front();
N -= 2;
}
else{
for(int i = 0; i < N; i++){
if(A[i] == a - 2*a){
int b = i;
while(b != 0){
swap(A[b], A[b - 1]);
b--;
ans++;
}
}
break;
}
A.pop_front();
A.pop_front();
N -= 2;
}
}
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... |