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