Submission #1156734

#TimeUsernameProblemLanguageResultExecution timeMemory
1156734ZflopXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
void solve(int N) {
	vector<int>v(N + 1);
	v[1] = N;
	int d = query(1,2);
	v[2] = N - d;
	for (int i = 3; i <= N;++i) {
		int a = query(i - 2,i);
		d = abs(v[i - 1] - v[i - 2]);
		//cout << d << ' ' << a << ' ' << v[i - 1] << ' ' << v[i - 2] << ' ' << i << '\n';
		if (d == a) {
			int dif = query(i - 1,i);
			if (v[i - 1] > v[i - 2]) {
				v[i] = v[i - 1] - dif;
				}
			else
				v[i] = v[i - 1] + dif;
			}
		else {
			int r = abs(v[i - 1] - v[i - 2]);
			int dif = query(i - 1,i);
			if (dif + r == a) {
				if (v[i - 1] > v[i - 2])
					v[i] = v[i - 1] + dif;
				else
					v[i] = v[i - 1] - dif;
				}
			else {
				if (v[i - 2] > v[i - 1])
					v[i] = v[i - 1] + dif;
				else
					v[i] = v[i - 1] - dif;
				}
			}
		}
	int mn = v[1];
	for (int i = 1; i <= N;++i) 
		mn = min(mn,v[i]);
	for (int i = 1; i <= N;++i)
		answer(i,v[i] - mn + 1);
	}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:6:17: error: 'query' was not declared in this scope
    6 |         int d = query(1,2);
      |                 ^~~~~
xylophone.cpp:41:17: error: 'answer' was not declared in this scope
   41 |                 answer(i,v[i] - mn + 1);
      |                 ^~~~~~