# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110933 | imsifile | On the Grid (FXCUP4_grid) | C++98 | 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 <vector>
#include <stdio.h>
using namespace std;
int N, rot[1010], sm[1010];
int Put(){
vector<int> v;
for(int i=0; i<N; i++) v.push_back(rot[i]);
return PutDisks(v)-N;
}
void Rotate(int X){
int tmp=rot[0];
for(int i=0; i<X-1; i++) rot[i]=rot[i+1];
rot[X-1]=tmp;
}
void SortDisks(int N_) {
N = N_;
for(int i=0; i<N; i++) rot[i]=i+1;
for(int i=N; i>1; i--){
while(1){
int x = Put(); Rotate(i);
if(x == i-1) break;
}
}
for(int i=0; i<N; i++) sm[rot[i]]=i+1;
for(int i=1; i<=N; i++) Report(sm[i]);
}