# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829356 | JoksimKaktus | Arranging Shoes (IOI19_shoes) | C++17 | 1077 ms | 3124 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>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;
long long count_swaps(vector <int> S){
long long res = 0;
for(int i = 0;i < S.size();i++){
if(S[i] == 0){
continue;
}else if(S[i] < 0){
int zero = 0;
for(int j = i+1;j < S.size();j++){
if(S[j] == -S[i]){
res += j-(i+1) - zero;
S[j] = 0;
S[i] = 0;
break;
}else if(S[j] == 0){
zero++;
}
}
}else{
int zero = 0;
for(int j = i+1;j < S.size();j++){
if(-S[j] == S[i]){
res += j-(i) - zero;
S[j] = 0;
S[i] = 0;
break;
}else if(S[j] == 0){
zero++;
}
}
}
}
return res;
}
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... |