제출 #1290646

#제출 시각아이디문제언어결과실행 시간메모리
1290646bilgetux38Xylophone (JOI18_xylophone)C++20
0 / 100
1 ms332 KiB
#include "xylophone.h"


static int A[5000];

void solve(int N) {

	int vec2[N-1];
	int vec3[N-2];
	int vecy[N];
	int vecs[N];
	int vecd[N];
	int vect[N];
	int vec[N];
	for (int i = 0; i < N-1; ++i)
	{
		vec2[i] = query(i+1, i+2);
	}
	for (int i = 0; i < N-2; ++i)
	{
		vec3[i] = query(i+1, i+3);
	}
	vecy[0] = 1;
	for (int i = 0; i < N-2; ++i)
	{
		if (vec2[i] + vec2[i+1] == vec3[i])
			vecy[i+1] = vecy[i];
		else
			vecy[i+1] = vecy[i] ^ 1;
	}
	vecs[0] = 0;
	for (int i = 0; i < N-1; ++i)
	{
		if (vecy[i] == 1)
			vecs[i+1] = vecs[i] + vec2[i];
		else
			vecs[i+1] = vecs[i] - vec2[i];
	}
	int mxx = -1 * __INT_MAX__ +1;
	int mnn = __INT_MAX__ -1;
	for (int i = 0; i < N; ++i)
	{
		if (vecs[i] > mxx)
			mxx = vecs[i];
		if (vecs[i] < mnn)
			mnn = vecs[i];
	}
	for (int i = 0; i < N; ++i)
	{
		vecd[i] = vecs[i] - mnn +1;
		vect[i] = mxx - vecs[i] +1;
	}
	int d1 = 0, dN = 0, t1 = 0, tN = 0;
	for (int i = 0; i < N; ++i)
	{
		if (vecd[i] > vecd[dN])
			dN = i;
		if (vecd[i] < vecd[dN])
			d1 = i;
	}
	if (d1 < dN)
	{
		for(int i = 0; i < N; i++) 
		{
			answer(i+1, vecd[i]);
		}
	}
	else
	{
		for(int i = 0; i < N; i++) 
		{
			answer(i+1, vect[i]);
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...