답안 #995967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995967 2024-06-10T06:23:34 Z cowwycow Xylophone (JOI18_xylophone) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pii = pair<ll, ll>;

void file(){
}

const int maxn = 1e4 + 5;
ll a[maxn], type[maxn], out[maxn];

void solve (){
	int n; cin >> n;
	a[2] = query(1, 2);
	type[2] = 0;
	ll last = a[2];
	for(int i = 3; i <= n; i++){
		ll q = query(i - 1, i), sus = query(i - 2, i);
		a[i] = q;
		if(last + q == sus){
			type[i] = type[i - 1];
		}else{
			type[i] = !type[i - 1];
		}
		last = q;
	}
	for(int i = 1; i <= n; i++){
		out[i] = out[i - 1] + a[i] * (-type[i] * 2 + 1);
	}
	int maxpos = 1, minpos = 1;
	for(int i = 2; i <= n; i++){
		if(out[maxpos] < out[i]){
			maxpos = i;
		}
		if(out[minpos] > out[i]){
			minpos = i;
		}
	}
	if(maxpos < minpos){
		for(int i = 1; i <= n; i++){
			type[i] = !type[i];
			out[i] = out[i - 1] + a[i] * (-type[i] * 2 + 1);
		}
	}
	ll in = 1e18;
	for(int i = 1; i <= n; i++){
		in = min(in, out[i]);
	}
	for(int i = 1; i <= n; i++){
		out[i] = out[i] - in + 1;
	}
	for(int i = 1; i <= n; i++){
		answer(i, out[i]);
	}
}

int main(){
	file();
	solve();
}

Compilation message

xylophone.cpp: In function 'void solve()':
xylophone.cpp:15:9: error: 'query' was not declared in this scope
   15 |  a[2] = query(1, 2);
      |         ^~~~~
xylophone.cpp:21:18: error: 'sus' was not declared in this scope
   21 |   if(last + q == sus){
      |                  ^~~
xylophone.cpp:54:3: error: 'answer' was not declared in this scope
   54 |   answer(i, out[i]);
      |   ^~~~~~