Submission #67315

# Submission time Handle Problem Language Result Execution time Memory
67315 2018-08-13T22:05:16 Z LushoPlusPlus Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include "xylophone.h"
#include <iostream>
#include <algorithm>

using namespace std;

//static int A[5000];

//int M[5010][5010];
int A[5010];
int Sum[5010];
int Dos[5010];
bool Usado[5010];
//int query(i,i+2)[5010];
int n;

int BS_Izq(int a,int b,int Num){
	int mid,B=b;
	while(b-a>1){
		//cout<<a<<" "<<b<<endl;
		mid=(a+b)/2;
		if(query(mid,B)!=Num){
			b=mid;
		}else{
			a=mid;
		}
	}
	return a;
}

void Mostrar(){
	for(int i=0;i<n;i++){
		cout<<A[i]<<" ";
	}
	cout<<endl;
}

int Solve2(int a,int b,int c){
	int mini=min(a,min(b,c));
	int maxi=max(a,max(b,c));
	return maxi-mini;
}

void Solve(int N) {
	n=N;
	int i=0,j=n,opc1,opc2;
	int Pos=BS_Izq(i,j-1,n-1);
	for(int i=0;i<n-1;i++){
		Dos[i]=query(i,i+1);
	}
	/*for(int i=0;i<n-2;i++){
		query(i,i+2)[i]=query(i,i+2);
	}*/
	Usado[0]=true;
	if(Pos>0) A[Pos-1]=Dos[Pos-1];
	A[Pos+1]=Dos[Pos];
	for(int i=Pos-2;i>=0;i--){
		opc1=A[i+1]+Dos[i];
		opc2=A[i+1]-Dos[i];
		if(opc1>=n or opc1<=0 or Usado[opc1]==true){
			A[i]=opc2;
			Usado[opc2]=true;
		}
		else if(opc2>=n or opc2<=0 or Usado[opc2]==true){
			A[i]=opc1;
			Usado[opc1]=true;
		}
		else{
			int o1=Solve2(opc1,A[i+1],A[i+2]);
			if(o1==query(i,i+2)){
				A[i]=opc1;
				Usado[opc1]=true;
			}else{
				A[i]=opc2;
				Usado[opc2]=true;
			}
		}
	}
	for(int i=Pos+2;i<n;i++){
		opc1=A[i-1]+Dos[i-1];
		opc2=A[i-1]-Dos[i-1];
		if(opc1>=n or opc1<=0 or Usado[opc1]==true){
			A[i]=opc2;
			Usado[opc2]=true;
		}
		else if(opc2>=n or opc2<=0 or Usado[opc2]==true){
			A[i]=opc1;
			Usado[opc1]=true;
		}
		else{
			int o1=Solve2(A[i-2],A[i-1],opc1);
			if(o1==query(i-2,i)){
				A[i]=opc1;
				Usado[opc1]=true;
			}else{
				A[i]=opc2;
				Usado[opc2]=true;
			}
		}
	}
	for(int i=0;i<n;i++){
		answer(i,A[i]);
	}
	//Mostrar();
	/*for(int i=0;i<n;i++){
		cout<<Dos[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<query(i,i+2)[i]<<" ";
	}
	cout<<endl;
	cout<<"Pos:"<<Pos<<endl;
	cout<<endl;
	*/
	return;
}

Compilation message

/tmp/ccatlmdt.o: In function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status