Submission #146229

# Submission time Handle Problem Language Result Execution time Memory
146229 2019-08-22T23:40:27 Z Diuven Xylophone (JOI18_xylophone) C++14
0 / 100
4 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 x = query(i-2, i);
		int sg = A[i-1]>A[i-2] ? 1 : -1;
		if(x!=P[i-1]+P[i]) sg *= -1;
		A[i] = A[i-1] + sg*P[i];
	}

	int m = *min_element(A+1, A+n+1);
	for(int i=1; i<=n; i++) A[i] -= m-1;
	int x=-1, y=-1;
	for(int i=1; i<=n; i++) if(A[i]==1) x=i; else if(A[i]==n) y=i;
	if(x>y) reverse(A+1, A+n+1);
	for(int i=1; i<=n; i++) answer(i, A[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Incorrect 4 ms 376 KB Wrong Answer [7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Incorrect 4 ms 376 KB Wrong Answer [7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Incorrect 4 ms 376 KB Wrong Answer [7
6 Halted 0 ms 0 KB -