Submission #146231

# Submission time Handle Problem Language Result Execution time Memory
146231 2019-08-22T23:49:12 Z Diuven Xylophone (JOI18_xylophone) C++14
0 / 100
2 ms 376 KB
#include "xylophone.h"
#include <algorithm>
using namespace std;

static int P[5001], A[5001];

void solve(int n){
	for(int i=2; i<=n; i++) P[i] = query(i-1, i);
	A[1] = 0; A[2] = P[2];

	for(int i=3; i<=n; i++){
		int sg = A[i-1]>A[i-2] ? 1 : -1;
		if(query(i-2, i)!=P[i-1]+P[i]) sg *= -1;
		A[i] = A[i-1] + sg*P[i];
	}

	int x = min_element(A+1, A+n+1)-A;
	int y = max_element(A+1, A+n+1)-A;
	for(int i=1; i<=n; i++) A[i] -= A[x]-1;
	if(x>y) for(int i=1; i<=n; i++) A[i] = n-A[i]+1;

	for(int i=1; i<=n; i++) answer(i, A[i]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [7
2 Halted 0 ms 0 KB -