# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
149453 | 20190901 (#200) | Bulb Game (FXCUP4_bulb) | C++17 | 0 ms | 0 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 "grid.h"
#include <iostream>
#define swap(a, b) (a^=b^=a^=b)
std::vector<int> solve(std::vector<int> &a)
{
std::vector<int> ans(a.size());
for(int i=0; i<ans.size(); i++)
{
ans[a[i]]=i+1;
}
return ans;
}
std::vector<int> SortDisks(int N) {
std::vector<int> res(N), a(N, -1);
for(int i=0; i<N; i++)
res[i]=i;
for(int i=N-1; i>=0; i--)
{
for(int j=1; j<=i; j++)
{
int t=PutDisks(res);
if(t==N) return solve(res);
if(t-N==i)
{
a[res[0]]=i;
swap(res[0], res[i]);
break;
}
swap(res[0], res[j]);
}
}
return solve(res);
}