답안 #129457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129457 2019-07-12T09:12:37 Z antimirage 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include "gondola.h"
#include "grader.cpp"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int b[N], ind[N], mx, sz, cnt[N];

int valid(int n, int a[]) {
	int pos = -1;
	
	for (int i = 0; i < n; i++) {
		if (a[i] <= n) {
			pos = i;
		}
		cnt[a[i]]++;
		
		if (cnt[a[i]] > 1)
			return 0;
	}
	if (pos == -1) {
		return 1;
	} else {
		assert(a[pos] <= n);
		int cn = a[pos];
		for (int i = (pos + 1) % n; i != pos; i = (i + 1) % n) {
			cn++;
			if (cn > n)
				cn -= n;
			if (a[i] > n) {
				continue;
			}
			if (a[i] != cn) {
				return 0;
			}
		}
	}
	return 1;
}
int replacement(int n, int a[], int ans[]) {
	memset(ind, -1, sizeof(ind));
	int pos = -1;
	
	for (int i = 0; i < n; i++) {
		if (a[i] <= n) {
			pos = i;
		}
		if (a[i] > a[mx]) {
			mx = i;
		}
		ind[a[i]] = i;
	}
	if (pos == -1) {
		for (int i = 0; i < n; i++) {
			b[i] = i + 1;
		}
	}
	else {
		int cn = a[pos];
		b[pos] = a[pos];
		for (int i = (pos + 1) % n; i != pos; i = (i + 1) % n) {
			cn++;
			if (cn > n)
				cn -= n;
			b[i] = a[pos] + cn;
			
		}
	}
	for (int i = n + 1; i <= a[mx]; i++) {
		if (ind[i] == -1) {
			ans[sz++] = b[mx];
			b[mx] = i;
		}
		else {
			ans[sz++] = b[ind[i]];
			b[ind[i]] = i;
		}
	}
	return sz;
}

int countReplacement(int n, int inputSeq[]) {
	return -3;
}

Compilation message

/tmp/ccJaaqQX.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccVnaiAW.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccJaaqQX.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/ccVnaiAW.o:(.bss+0xc65dc0): first defined here
/tmp/ccJaaqQX.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/ccVnaiAW.o:(.bss+0xb71b60): first defined here
collect2: error: ld returned 1 exit status