Submission #111166

# Submission time Handle Problem Language Result Execution time Memory
111166 2019-05-14T01:16:17 Z imsifile On the Grid (FXCUP4_grid) C++
Compilation error
0 ms 0 KB
#include "grid.h"
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int N, rot[2010], 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 am){ // rot[0 ~ X-1] left am
	reverse(rot, rot+am);
	reverse(rot+am, rot+X);
	reverse(rot, rot+X);
}

void SortDisks(int N_) {
	N = N_;
	for(int i=0; i<N; i++) rot[i]=i+1;

	for(int i=N; i>1; i--){
		int pv = Put();
		for(int X=i; X>1;){
			Rotate(X, X/2);
			int nx = Put();
			if(pv > nx) Rotate(X, (X+1)/2), X = X/2;
			else pv = nx, X = (X+1)/2;
		}
		sm[rot[0]] = 1+pv;
		Rotate(i, 1);
		for(int j=i; j<N; j++){
			if(sm[rot[j-1]] > sm[rot[j]]) swap(rot[j-1], rot[j]);
		}
	}
	sm[rot[0]] = 1;

	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:40:26: error: 'Report' was not declared in this scope
  for(int i=1; i<=N; i++) Report(sm[i]);
                          ^~~~~~
grid.cpp:40:26: note: suggested alternative: 'qsort'
  for(int i=1; i<=N; i++) Report(sm[i]);
                          ^~~~~~
                          qsort