Submission #78518

# Submission time Handle Problem Language Result Execution time Memory
78518 2018-10-05T14:55:25 Z Origims Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include <xylophone.h>

void solve (int n) {
	int a[N], d1[N], d2[N];
	for (int i = 0; i < n - 1; i++)
		d1[i] = query(i + 1, i + 2);
	for (int i = 0; i < n - 2; i++)
		d2[i] = query(i + 1, i + 3);
	a[0] = 0, a[1] = d1[1];
	bool tmp;
	for (int i = 2; i < n; i++) {
		tmp = 1 - (d1[i - 1] + d1[i] != d2[i - 1]);
		a[i] = a[i - 1] + (tmp ? +1 : -1) * d1[i - 1];
	}
	int mx = 0, mxi = 0, mi = 0, mii = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > mx)
			mx = a[i], mxi = i;
		if (a[i] < mi)
			mi = a[i], mii = i;
	}
	if (mii < mxi)
		for (int i = 0; i < n; i++)
			answer(i + 1, a[i] - mi + 1);
	else
		for (int i = 0; i < n; i++)
			answer(i + 1, mx - a[i] + 1);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:4:8: error: 'N' was not declared in this scope
  int a[N], d1[N], d2[N];
        ^
xylophone.cpp:6:3: error: 'd1' was not declared in this scope
   d1[i] = query(i + 1, i + 2);
   ^~
xylophone.cpp:8:3: error: 'd2' was not declared in this scope
   d2[i] = query(i + 1, i + 3);
   ^~
xylophone.cpp:9:2: error: 'a' was not declared in this scope
  a[0] = 0, a[1] = d1[1];
  ^
xylophone.cpp:9:19: error: 'd1' was not declared in this scope
  a[0] = 0, a[1] = d1[1];
                   ^~
xylophone.cpp:12:35: error: 'd2' was not declared in this scope
   tmp = 1 - (d1[i - 1] + d1[i] != d2[i - 1]);
                                   ^~