# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1177766 | alwaus424 | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
int64_t count_swaps(vector<int> S) {
int64_t swaps = 0;
int n = S.size();
for(int i = 0;i<n*2;i++){
if(i % 2 == 0 && S[i] > 0 ){
int nex1 = 0;
for(int j = i+1;j<2*n;j++){
if(S[j] == -1){
nex1 = j;
break;
}
}
while(nex1 > i) {
swap(S[nex1] , S[nex1-1]);
nex1--;
swaps++;
}
}
else if(i & 1 && S[i] < 0){
int nex1 = 0;
for(int j = i+1;j<2*n;j++){
if(S[j] == 1){
nex1 = j;
break;
}
}
while(nex1 > i) {
# | 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... |