답안 #74326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74326 2018-08-31T10:07:43 Z Mamnoon_Siam Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

void detect_pitch(int N) {
	if(N == 2) {
		answer(0, 0);
		answer(1, 1);
		return;
	}
	vector<int> a(N), two(N), three(N);
	for(int i = 0; i < N - 1; i++) {
		two[i] = ask(i, i + 1);
		if(i < N - 2) three[i] = ask(i, i + 2);
	}
	a[1] = two[0];
	int tog = 1;
	for(int i = 2; i < N; i++) {
		if(three[i - 2] == two[i - 2] + two[i - 1]) {
			a[i] = tog ? a[i - 1] + two[i - 1] : a[i - 1] - two[i - 1];
		} else {
			a[i] = tog ? a[i - 1] - two[i - 1] : a[i - 1] + two[i - 1];
			tog ^= 1;
		}
	}
	int mxid, mnid, mx = -1e5, mn = 1e5;
	for(int i = 0; i < N; i++) {
		if(a[i] < mn) mn = a[i], mnid = i;
		if(a[i] > mx) mx = a[i], mxid = i;
	}
	if(mxid < mnid) {
		for(int &b : a) b = -b;
		swap(mn, mx);
		mx = -mx, mn = -mn;
	}
	for(int i = 0; i < N; i++) a[i] -= mn;
	for(int i = 0; i < N; i++) answer(i, a[i]);
}

Compilation message

xylophone.cpp: In function 'void detect_pitch(int)':
xylophone.cpp:13:12: error: 'ask' was not declared in this scope
   two[i] = ask(i, i + 1);
            ^~~