Submission #230191

# Submission time Handle Problem Language Result Execution time Memory
230191 2020-05-09T03:30:31 Z AngusRitossa Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 5010
int diff[MAXN], diffsign[MAXN];
void detect_pitch(int n) {
	for (int i = 0; i < n-1; i++) {
		diff[i] = ask(i, i+1);
	}
	for (int i = 0; i < n-2; i++) {
		int am = ask(i, i+2);
		if (am != diff[i]+diff[i+1]) diffsign[i+1] = 1;
	}
	for (int i = 1; i < n-1; i++) {
		if (diffsign[i] && diff[i-1] > 0) diff[i]*=-1;
		if (!diffsign[i] && diff[i-1] < 0) diff[i]*=-1;
	}
	int sum = accumulate(diff, diff+n-1, 0);
	if (sum < 0) {
		for (int i = 0; i < n-1; i++) diff[i]*=-1;
	}
	int mn = 0, val = 0;
	for (int i = 0; i < n-1; i++) {
		val += diff[i];
		mn = min(mn, val);
	}
	val = -mn;
	for (int i = 0; i < n; i++) {
		answer(i, val);
		val += diff[i];
	}
}

Compilation message

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