답안 #111330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111330 2019-05-14T19:51:25 Z vex Xylophone (JOI18_xylophone) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int d1[5005];
int d2[5005];
int zn[5005];

void solve(int n)
{
	for(int i=1;i<n;i++)d1[i]=query(i,i+1);
	for(int i=1;i<n-1;i++)d2[i]=query(i,i+2);
	
	zn[1]=1;
	for(int i=2;i<n-1;i++)
	{
		if(d1[i-1]+d1[i]==d2[i-1])zn[i]=zn[i-1];
		else zn[i]=-zn[i-1];
	}
	
	int tre=0;
	int minv=0;int minn=1;
	int maxv=0;int maxx=1;
	for(int i=2;i<=n;i++)
	{
		tre+=d1[i-1]*zn[i-1];
		if(tre>maxv)
		{
			maxv=tre;
			maxx=i;
		}
		if(tre<minv)
		{
			minv=tre;
			minn=i;
		}
	}
	
	int sgn=1;
	if(minn>maxx)
	{
		sgn=-sgn;
		swap(minn,maxx);
	}
	
	a[minn]=1;
	for(int i=minn+1;i<=n;i++)a[i]=a[i-1]+sgn*d1[i-1]*zn[i-1];
	for(int i=minn-1;i>0;i--)a[i]=a[i+1]-sgn*d1[i]*zn[i];
	
	for(int i=1;i<=n;i++)answer(i,a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:10:28: error: 'query' was not declared in this scope
  for(int i=1;i<n;i++)d1[i]=query(i,i+1);
                            ^~~~~
xylophone.cpp:11:30: error: 'query' was not declared in this scope
  for(int i=1;i<n-1;i++)d2[i]=query(i,i+2);
                              ^~~~~
xylophone.cpp:45:2: error: 'a' was not declared in this scope
  a[minn]=1;
  ^
xylophone.cpp:49:23: error: 'answer' was not declared in this scope
  for(int i=1;i<=n;i++)answer(i,a[i]);
                       ^~~~~~
xylophone.cpp:49:23: note: suggested alternative: 'assert'
  for(int i=1;i<=n;i++)answer(i,a[i]);
                       ^~~~~~
                       assert