# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465696 | tomsyd | Arranging Shoes (IOI19_shoes) | C++17 | 1084 ms | 5396 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;
bool ok(vector<int>& s){
for (int i=1; i<s.size(); i += 2){
if (s[i-1] < 0 and -s[i-1] == s[i]){
continue;
}
return false;
}
return true;
}
long long count_swaps(vector<int> s) {
vector<pair<int,int>> v;
for (int i=1; i<s.size(); ++i){
v.emplace_back(i-1,i);
}
int ans = 1e9;
if (ok(s)) ans = 0;
do{
vector<int> cp = s;
int cnt = 0;
for (auto j:v){
swap(cp[j.first],cp[j.second]);
++cnt;
if (ok(cp)) break;
}
ans = min(ans,cnt);
} while (next_permutation(v.begin(),v.end()));
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... |