Submission #763658

# Submission time Handle Problem Language Result Execution time Memory
763658 2023-06-22T15:10:26 Z vjudge1 Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 2e5 + 69;
ll ans[maxn],p[maxn],trio[maxn];
ll minn,maxx;
void solve(ll n){
	for(int i = 1;i<n;i++){
		p[i] = query(i,i+1);
	}
	for(int i = 1;i<n-1;i++){
		trio[i] = query(i,i+2);
	}
	ans[1] = 0;
	ans[2] = p[1];
	for(int i = 3;i<=n;i++){
		if(p[i-1] + p[i-2] == trio[i-2]){
			if(ans[i-1] > ans[i-2]){
				ans[i] = ans[i-1] + p[i-1];
			}else{
				ans[i] = ans[i-1] - p[i-1];
			}
		}else{
			if(ans[i-1] < ans[i-2]){
				ans[i] = ans[i-1] + p[i-1];
			}else{
				ans[i] = ans[i-1] - p[i-1];
			}
		}
	}
	minn = 1,maxx = 1;
	for(int i = 1;i<=n;i++){
		if(a[i] < a[minn]){
			minn = i;
		}
		if(a[i] > a[maxx]){
			maxx = i;
		}
	}
	ll temp = a[minn];
	for(int i = 1;i<=n;i++){
		a[i] = a[i] - temp + 1;
	}
	if(minn > maxx){
		for(int i = i<=n;i++){
			a[i] = n - a[i] + 1;
		}
	}
	for(int i = 1;i<=n;i++) answer(i,a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:9:10: error: 'query' was not declared in this scope
    9 |   p[i] = query(i,i+1);
      |          ^~~~~
xylophone.cpp:12:13: error: 'query' was not declared in this scope
   12 |   trio[i] = query(i,i+2);
      |             ^~~~~
xylophone.cpp:33:6: error: 'a' was not declared in this scope
   33 |   if(a[i] < a[minn]){
      |      ^
xylophone.cpp:36:6: error: 'a' was not declared in this scope
   36 |   if(a[i] > a[maxx]){
      |      ^
xylophone.cpp:40:12: error: 'a' was not declared in this scope
   40 |  ll temp = a[minn];
      |            ^
xylophone.cpp:45:23: error: expected ';' before ')' token
   45 |   for(int i = i<=n;i++){
      |                       ^
      |                       ;
xylophone.cpp:49:26: error: 'answer' was not declared in this scope
   49 |  for(int i = 1;i<=n;i++) answer(i,a[i]);
      |                          ^~~~~~