# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
602964 | definitelynotmee | Arranging Shoes (IOI19_shoes) | C++17 | 1083 ms | 3128 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;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using matrix = vector<vector<T>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
long long count_swaps(std::vector<int> v) {
int n = v.size();
ll resp = 0;
auto solve =[&](int id, auto solve)->void{
if(id >= n)
return;
int par;
for(int i = id+ 1; i < n; i++){
if(v[i] == v[id]*-1){
par = i;
break;
}
}
for(int i = par-1; i > id; i--){
swap(v[i],v[i+1]);
// for(int i : v){
// cout << i << ' ';
// }
// cout << '\n';
resp++;
}
if(v[id] > v[id+1]){
swap(v[id],v[id+1]), resp++;
// for(int i : v){
// cout << i << ' ';
// }
// cout << '\n';
}
solve(id+2,solve);
};
solve(0,solve);
return resp;
}
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... |