# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153574 | asifthegreat | Arranging Shoes (IOI19_shoes) | C++14 | 2 ms | 256 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>
using namespace std;
// #include <queue>
#include "shoes.h"
long long count_swaps(std::vector<int> s) {
int cnt = 0;
int sz = s.size();
for(int i = 0; i < s.size();i++){
if(i < sz/2)s[i] = -(i+1);
else s[i] = (i+1-sz/2);
}
for(int i = 0; i < sz;i++){
cout << s[i] << " ";
}cout << endl;
for(int i = 0; i < s.size();i++){
for(int j = i+1; j < s.size();j++){
if(s[i] == -s[j]){
for(int p = j;p > i+1;p--){
swap(s[p],s[p-1]);
cnt++;
}
if(i%2==0 and s[i] > 0)swap(s[i],s[i+1]),cnt++;
i++;
}
}
}
return cnt;
}
// int main() {
// int n;
// scanf("%d", &n);
// vector<int> S(2 * n);
// for(int i = 0; i < 2 * n; i++)
// scanf("%d", &S[i]);
// long long result = count_swaps(S);
// printf("%lld\n", result);
// return 0;
// }
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... |