Submission #896141

# Submission time Handle Problem Language Result Execution time Memory
896141 2023-12-31T22:12:08 Z starchan Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
void solve(int n)
{
	if(n == 2)
	{
		answer(1, 1);
		answer(2, 2);
		return;
	}
	vector<int> d(n+1);
	vector<int> d2(n+1);
	vector<int> a(n+1);
	for(int i = 2; i <= n; i++)
		d[i] = query(i-1, i);
	for(int i = 3; i <= n; i++)
		d2[i] = query(i-2, i);
	a[1] = 0;
	a[2] = d[i];
	for(int i = 3; i <= n; i++)
	{
		if(d2[i] == (d[i]+d[i-1]))
		{
			if(a[i-2] > a[i-1])
				a[i] = a[i-1]-d[i];
			else
				a[i] = a[i-1]+d[i];
		}
		else
		{
			if(a[i-2] > a[i-1])
				a[i] = a[i-1]+d[i];
			else
				a[i] = a[i-1]-d[i];
		}
	}
	in ok_min = {INF, -1};
	in ok_max = {-INF, -1};
	for(int i = 1; i <= n; i++)
		ok_min = min(ok_min, {a[i], i});
	for(int i = 1; i <= n; i++)
		ok_max = max(ok_max, {a[i], i});
	if(ok_min.s > ok_max.s)
	{
		for(int i = 1; i <= n; i++)
			a[i] = n+1-a[i];
	}
	for(int i = 1; i <= n; i++)
		answer(i, a[i]);
	return;
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:28:11: error: 'i' was not declared in this scope
   28 |  a[2] = d[i];
      |           ^