답안 #149422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149422 2019-09-01T06:27:17 Z GojekKawe(#3581, VinsenN, XxX, dexter) List of Unique Integers (FXCUP4_unique) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#include <stdio.h>
#include <stdlib.h>

static int N, arr[222], unq[222][222], chk[222];

static void my_assert(int TF, const char* message){
	if(!TF){ puts(message); exit(0); }
}

static int call_cnt = 0;
int UniqueCount(int R, int C){
	call_cnt++;
	my_assert(call_cnt <= 40000, "Wrong : Too Much Calls");
	my_assert(R >= 0 && C < N && R <= C, "Wrong : Invalid R, C");

	return unq[R][C];
}
vector<int> PickUnique (int N){
	int U[N];
	memset(U,0,N);
	if(UniqueCount(0,N-1)==UniqueCount(0,N-2)+1){
			U[N-1]=1;
		};
	if(UniqueCount(0,N-1)==UniqueCount(1,N-1)+1){
			U[0]=1;
		};
	for(int i=N-2; i>0;i--){
		if(UniqueCount(0,i)==UniqueCount(0,i-1)+1){
			if(UniqueCount(i,N-1)==UniqueCount(i+1,N-1)+1){
				U[i]=1;
			}
		}
	};
	vector<int> vect(U, U + sizeof(U)/sizeof(U[0]));
	return vect;
}
int main(){
	my_assert(scanf("%d", &N) == 1, "Error: Invalid Input");
	my_assert(2 <= N && N <= 200, "Error: Invalid Input");

	for(int i = 0; i < N; i++){
		my_assert(scanf("%d", &arr[i]) == 1, "Error: Invalid Input");
		my_assert(1 <= arr[i] && arr[i] <= 200, "Error: Invalid Input");
	}
	for(int i = 0; i < N; i++){
		int u = 0;
		for(int j = 1; j <= 200; j++) chk[j] = 0;
		for(int j = i; j < N; j++){
			chk[arr[j]]++;
			if(chk[arr[j]] == 1) u++;
			if(chk[arr[j]] == 2) u--;
			unq[i][j] = u;
		}
	}
	for(int i = 1; i <= 200; i++) chk[i] = 0;
	for(int i = 0; i < N; i++) chk[arr[i]]++;

	std::vector<int> rpd = PickUnique(N);
	my_assert((int) rpd.size() == N, "Wrong: Wrong Answer");
	for(int i = 0; i < N; i++){
		my_assert(rpd[i] == 0 || rpd[i] == 1, "Wrong: Wrong Answer");
		if(chk[arr[i]] == 1) my_assert(rpd[i], "Wrong : Wrong Answer");
		if(rpd[i]) my_assert(chk[arr[i]] == 1, "Wrong : Wrong Answer");
	}
	printf("Correct\n%d\n", call_cnt);
	return 0;
}

/*int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;i++){
		cin>>a[N];
	}
	PickUnique(N);
}*/

Compilation message

/tmp/ccKpy33U.o: In function `UniqueCount(int, int)':
grader.cpp:(.text+0x10): multiple definition of `UniqueCount(int, int)'
/tmp/ccUcQtUH.o:unique.cpp:(.text+0x10): first defined here
/tmp/ccKpy33U.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccUcQtUH.o:unique.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status