# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1030687 | fv3 | Arranging Shoes (IOI19_shoes) | C++14 | 1054 ms | 1048576 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;
typedef long long ll;
bool isValid(vector<int> v)
{
for (int i = 0; i < v.size(); i += 2)
{
if (v[i] > v[i+1] || v[i] != -v[i+1])
return false;
}
return true;
}
ll count_swaps(vector<int> s)
{
const int N = s.size() / 2;
map<vector<int>, int> visited;
visited[s] = 0;
queue<vector<int>> q;
q.push(s);
while (!q.empty())
{
vector<int> v = q.front();
int d = visited[v];
if (isValid(v))
{
return d;
}
q.pop();
for (int i = 0; i < 2 * N - 1; i++)
{
swap(v[i], v[i+1]);
if (visited.count(v) == 0)
{
visited[v] = d + 1;
q.push(v);
}
swap(v[i], v[i+1]);
}
}
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... |