답안 #130612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130612 2019-07-15T18:02:23 Z tutis Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;
void solve(int N)
{
	int A[N + 1];
	A[1] = 0;
	A[2] = A[1] + query(1, 2);
	for (int i = 3; i <= N; i++)
	{
		int x = query(i - 1, i);
		int y = query(i - 2, i);
		if (A[i - 1] > A[i - 2])
		{
			if (y == x + A[i - 1] - A[i - 2])
				A[i] = A[i - 1] + x;
			else
				A[i] = A[i - 1] - x;
		}
		else
		{
			if (y == x + A[i - 2] - A[i - 1])
				A[i] = A[i - 1] - x;
			else
				A[i] = A[i - 1] + x;
		}
	}
	auto it1 = min_element(A + 1, A + (N + 1));
	auto itn = max_element(A + 1, A + (N + 1));
	if (it1 > itn)
	{
		reverse(A + 1, A + (N + 1));
	}
	int x = *min_element(A, A + (N + 1));
	for (int i = 1; i <= N; i++)
	{
		A[i] -= x;
		A[i]++;
		answer(i, A[i]);
	}
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:16: error: 'query' was not declared in this scope
  A[2] = A[1] + query(1, 2);
                ^~~~~
xylophone.cpp:39:3: error: 'answer' was not declared in this scope
   answer(i, A[i]);
   ^~~~~~
xylophone.cpp:39:3: note: suggested alternative: 'assert'
   answer(i, A[i]);
   ^~~~~~
   assert