# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999902 | KasymK | Arranging Shoes (IOI19_shoes) | C++17 | 1105 ms | 337444 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;
#define ll long long
#define ff first
#define ss second
bool check(vector<int> v){
int n = (int)v.size()/2;
bool ok = true;
for(int i = 0; i < n; ++i)
ok &= (v[2*i] < v[2*i+1] and v[2*i]*(-1) == v[2*i+1]);
return ok;
}
ll count_swaps(vector<int> v){
int n = (int)v.size();
queue<pair<vector<int>, ll>> q;
vector<vector<int>> vis;
q.push({v, 0});
vis.push_back(v);
while(!q.empty()){
auto x = q.front();
q.pop();
if(check(x.ff))
return x.ss;
for(int i = 0; i < n-1; ++i){
swap(x.ff[i], x.ff[i+1]);
int ok = 1;
for(auto i : vis)
ok &= (i != x.ff);
if(ok){
vis.push_back(x.ff);
q.push({x.ff, x.ss+1});
}
swap(x.ff[i], x.ff[i+1]);
}
}
}
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... |