Submission #236946

# Submission time Handle Problem Language Result Execution time Memory
236946 2020-06-04T05:29:15 Z crossing0ver Gondola (IOI14_gondola) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "gondola.h"
using namespace std;
const int MAXN = 1E5+5;
int n,a[MAXN];
int valid(int n1, int inputSeq[]) {
	n = n1;
	int pos = -1;
	for (int i = 0; i < n; i++) {
		a[i] = inputSeq[i];
		if (a[i] <= n) 
			pos = i;
	}
	if (pos != -1) {
		int x = (a[pos] - pos - 1)%n;
		if (x <0) x+= n;	
		int b[MAXN];
		for (int i = 0; i < n; i++) {
			b[(x + i)%n] = a[i];
		}
		for (int i = 0;i < n; i++)
			a[i] = b[i];
	}
	set<int> s;
	for (int i = 0; i < n; i++) {
		if (a[i] < n) {
			if (a[i] != i + 1) return 0;
		}
		s.insert(a[i]);
	}
	if (s.size() != n) return 0;
	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]);
int countReplacement(int n, int inputSeq[]);
 /*
main() {
	int n;
	cin >> n;
	int inputseq[n];
	for (int i = 0;i  < n; i++)
		cin >> inputseq[i];
	cout << valid(n,inputseq);
}*/

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (s.size() != n) return 0;
      ~~~~~~~~~^~~~
/tmp/ccGxFXwV.o: In function `main':
grader.cpp:(.text.startup+0xc3): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0x106): undefined reference to `replacement'
collect2: error: ld returned 1 exit status