제출 #1272642

#제출 시각아이디문제언어결과실행 시간메모리
1272642raditya_noorXylophone (JOI18_xylophone)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

void solve(){
	int n; cin >> n;
	int diff[n + 1] = {0};
	for(int i = 2; i <= n; i++){
		diff[i] = query(i - 1, i);
	}
	int mult[n + 1] = {0}; mult[1] = 1, mult[2] = 1;
	for(int i = 3, add; i <= n; i++){
		add = query(i - 2, i);
		if(add < diff[i - 1] + diff[i]) mult[i] = -1;
		else mult[i] = 1;
	}
	int arr[n + 1] = {0}, curm = mult[1], add = n;
	for(int i = 2; i <= n; i++){
		curm *= mult[i];
		arr[i] = arr[i - 1] + curm * diff[i];
		add = min(add, n - arr[i]);
	}
//	for(int i = 1; i <= n; i++) cout << arr[i] << ' '; cout << endl;
	bool mun = 0; int madd = 0;
	for(int i = 1; i <= n; i++){
		arr[i] += add;
		if(arr[i] == n && !mun){
//			cout << madd << endl;
			madd = n + 1;
		}else if(arr[i] == 1) mun = 1;
//		cout << madd << endl;
	}
//	for(int i = 1; i <= n; i++) cout << diff[i] << ' '; cout << endl;
//	for(int i = 1; i <= n; i++) cout << mult[i] << ' '; cout << endl;
//	cout << add << ' ' << madd << endl;
	for(int i = 1; i <= n; i++){
//		cout << "answer(" << i << ", " << abs(madd - arr[i]) << ')' << endl;
		answer(i, abs(madd - arr[i]));
	}
}

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve()':
xylophone.cpp:8:27: error: 'query' was not declared in this scope
    8 |                 diff[i] = query(i - 1, i);
      |                           ^~~~~
xylophone.cpp:12:23: error: 'query' was not declared in this scope
   12 |                 add = query(i - 2, i);
      |                       ^~~~~
xylophone.cpp:37:17: error: 'answer' was not declared in this scope
   37 |                 answer(i, abs(madd - arr[i]));
      |                 ^~~~~~