Submission #67313

# Submission time Handle Problem Language Result Execution time Memory
67313 2018-08-13T22:03:55 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 ask(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(ask(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 Solve(int a,int b,int c){
	int mini=min(a,min(b,c));
	int maxi=max(a,max(b,c));
	return maxi-mini;
}

void detect_pitch(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]=ask(i,i+1);
	}
	/*for(int i=0;i<n-2;i++){
		ask(i,i+2)[i]=ask(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=Solve(opc1,A[i+1],A[i+2]);
			if(o1==ask(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=Solve(A[i-2],A[i-1],opc1);
			if(o1==ask(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<<ask(i,i+2)[i]<<" ";
	}
	cout<<endl;
	cout<<"Pos:"<<Pos<<endl;
	cout<<endl;
	*/
	return;
}

Compilation message

xylophone.cpp: In function 'int BS_Izq(int, int, int)':
xylophone.cpp:22:6: error: 'ask' was not declared in this scope
   if(ask(mid,B)!=Num){
      ^~~
xylophone.cpp: In function 'void detect_pitch(int)':
xylophone.cpp:49:10: error: 'ask' was not declared in this scope
   Dos[i]=ask(i,i+1);
          ^~~
xylophone.cpp:70:11: error: 'ask' was not declared in this scope
    if(o1==ask(i,i+2)){
           ^~~
xylophone.cpp:92:11: error: 'ask' was not declared in this scope
    if(o1==ask(i-2,i)){
           ^~~