Submission #1272645

#TimeUsernameProblemLanguageResultExecution timeMemory
1272645raditya_noorXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

void solve(int n){
	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]));
	}
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:6:13: error: declaration of 'int n' shadows a parameter
    6 |         int n; cin >> n;
      |             ^
xylophone.cpp:5:16: note: 'int n' previously declared here
    5 | void solve(int n){
      |            ~~~~^