# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
597552 | FatihSolak | Arranging Shoes (IOI19_shoes) | C++17 | 1089 ms | 1876 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;
long long count_swaps(vector<int> s){
long long ans = 0;
int n = s.size();
long long x = n/2;
for(int i = 0;i<n;i+=2){
int mini = -1;
int val = 1e9;
for(int j = i;j<n;j++){
if(s[j] < 0){
for(int c = i;c<n;c++){
if(s[c] == -s[j]){
int nowval = j - i;
nowval += (c - (i+1)) + (j >c);
if(nowval < val){
val = nowval;
mini = s[j];
}
break;
}
}
}
}
for(int j = i;j<n;j++){
if(s[j] == mini){
for(int c = j-1;c>=i;c--){
swap(s[c],s[c+1]);
ans++;
}
break;
}
}
for(int j = i+1;j<n;j++){
if(s[j] == -s[i]){
for(int c = j-1;c>=i+1;c--){
swap(s[c],s[c+1]);
ans++;
}
break;
}
}
}
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... |