#include "grid.h"
#include <vector>
#include <stdio.h>
using namespace std;
int N, sm[1010], rcn, rot[1010], rvd[1010], chk[1010]; // rvd[i]: disk number of size i
int Put(){
vector<int> v;
for(int i=1; i<=N; i++) v.push_back(sm[i]);
return PutDisks(v)-N;
}
void fill(){
for(int i=0; i<rcn; i++) sm[i+1]=rot[i];
for(int i=rcn, j=1; j<=N; j++){
if(chk[j]) sm[++i]=rvd[j];
}
}
void SortDisks(int N_) {
rcn = N = N_;
for(int i=0; i<N; i++) rot[i]=i+1;
fill();
int ini=Put(), nxt;
while(ini && rcn>1){
int tmp=rot[rcn-1];
for(int i=rcn-1; i>=0; i--) rot[i+1]=rot[i];
rot[0]=tmp;
fill(); nxt=Put();
if(nxt >= ini){
rcn--;
rvd[1+nxt]=rot[0], chk[1+nxt]=1;
for(int i=0; i<rcn; i++) rot[i]=rot[i+1];
}
else ini=nxt;
}
for(int i=1, j=0; i<=N; i++){
if(chk[i]) sm[rvd[i]]=i;
else sm[rot[j++]]=i;
}
for(int i=1; i<=N; i++) Report(sm[i]);
}
Compilation message
grid.cpp: In function 'void SortDisks(int)':
grid.cpp:20:6: error: ambiguating new declaration of 'void SortDisks(int)'
void SortDisks(int N_) {
^~~~~~~~~
In file included from grid.cpp:1:0:
grid.h:7:18: note: old declaration 'std::vector<int> SortDisks(int)'
std::vector<int> SortDisks(int N);
^~~~~~~~~
grid.cpp:43:26: error: 'Report' was not declared in this scope
for(int i=1; i<=N; i++) Report(sm[i]);
^~~~~~
grid.cpp:43:26: note: suggested alternative: 'short'
for(int i=1; i<=N; i++) Report(sm[i]);
^~~~~~
short