Submission #1305923

#TimeUsernameProblemLanguageResultExecution timeMemory
1305923quollcucumber`Xylophone (JOI18_xylophone)C++20
0 / 100
0 ms332 KiB
#include "xylophone.h"

#include <bits/stdc++.h>

using namespace std;

 

void solve(int N) {

	cout<<query(N-1, N)<<'\n';

	vector<int> dif;

	for(int i = 1; i <= N-1; i++){

		dif.push_back(query(i, i +1));

	}

	vector<int> updown;

	for(int i = 1; i <= N -2; i++){

		updown.push_back(query(i, i + 2));

	}

	// for(int i = 0; i < N - 2; i ++){

	// 	cout<<updown[i]<<' ';

	// }

	// cout<<'\n';

	// for(int i = 0; i < N - 1; i ++){

	// 	cout<<dif[i]<<' ';

	// }

	// cout<<'\n';

	bool up = true;

	int total = 0;

	vector<int> ans = {0};

	for(int i = 0; i < N- 1; i++){

		if(up){

			ans.push_back( total + dif[i]);

			total += dif[i];

		}else{

			ans.push_back( total - dif[i]);

			total -= dif[i];

		}

		if(i != N-2){

			if(updown[i] == dif[i] + dif[i + 1]){

				up = up;

			}else{

				up = 1 - up;

			}

		}

	}

	int minval = INT_MAX;

	for(int i = 0; i < N; i++){

		minval = min(minval, ans[i]);

	}

	for(int i = 0; i < N; i++){

		ans[i] += (-1 * minval) + 1;

	}

	for(int i : ans){

		// cout<<i<<'\n';

	}

	for(int i = 0; i < N; i++){

		if(ans[i] == N){

			break;

		}else if(ans[i] == 1){

			for(int i = 0; i < N; i++){

				answer(i+1, ans[i]);

			}

			return;

		}

	}

 

 

 

 

 

	 up = false;

	 total = 0;

	 ans.clear();

	 ans.push_back(0);

	for(int i = 0; i < N- 1; i++){

		if(up){

			ans.push_back( total + dif[i]);

			total += dif[i];

		}else{

			ans.push_back( total - dif[i]);

			total -= dif[i];

		}

		if(i != N-2){

			if(updown[i] == dif[i] + dif[i + 1]){

				up = up;

			}else{

				up = 1 - up;

			}

		}

	}

	 minval = INT_MAX;

	for(int i = 0; i < N; i++){

		minval = min(minval, ans[i]);

	}

	for(int i = 0; i < N; i++){

		ans[i] += (-1 * minval) + 1;

	}

	for(int i : ans){

		// cout<<i<<'\n';

	}

	for(int i = 0; i < N; i++){

		answer(i+1, ans[i]);

	}

	return;	

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...