답안 #73530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73530 2018-08-28T11:40:54 Z Pajaraja Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[5007],s[5007],sgn[5007],inv[5007];
void detect_pitch(int n)
{
	int znk=1;
	sgn[0]=1;
	for(int i=0;i<n-1;i++) s[i]=ask(i,i+1);
	for(int i=2;i<n;i++)
	{
		if(s[i-2]+s[i-1]==ask(i-2,i)) sgn[i-1]=sgn[i-2];
		else sgn[i-1]=-sgn[i-2];
	}
	int m=0,cur=0;
	for(int i=1;i<n;i++)
	{
		cur+=sgn[i-1]*s[i-1];
		m=min(m,cur);
	}
	cur=-m;
	a[0]=-m;
	for(int i=0;i<n;i++)
	{
		cur+=sgn[i-1]*s[i-1];
		a[i]=cur;
	}
	for(int i=0;i<n;i++) inv[a[i]]=i;
	if(inv[0]>inv[n-1]) for(int i=0;i<n;i++) a[i]=n-1-a[i];
	for(int i=0;i<n;i++) answer(i,a[i]);
}

Compilation message

xylophone.cpp: In function 'void detect_pitch(int)':
xylophone.cpp:9:30: error: 'ask' was not declared in this scope
  for(int i=0;i<n-1;i++) s[i]=ask(i,i+1);
                              ^~~
xylophone.cpp:12:21: error: 'ask' was not declared in this scope
   if(s[i-2]+s[i-1]==ask(i-2,i)) sgn[i-1]=sgn[i-2];
                     ^~~
xylophone.cpp:7:6: warning: unused variable 'znk' [-Wunused-variable]
  int znk=1;
      ^~~