Submission #444585

# Submission time Handle Problem Language Result Execution time Memory
444585 2021-07-14T09:53:39 Z fuad27 Xylophone (JOI18_xylophone) C++14
0 / 100
2 ms 200 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int N) {
	vector<int> v(N+1, 0);
	int l = 0, r = N, one = N;
	while(l<=r) {
		int mid = (l+r)>>1;
		if(query(mid, N) == N-1) {
			one = mid;
			l = mid+1;
		}
		else {
			r = mid - 1;
		}
	}
	v[one] = 1;
	for(int i = one + 1; i<=N;i++) {
		int val = query(i-1, i);
		if(v[i-1] + val > N) {
			v[i] = v[i-1] - val;
		}
		else {
			v[i] = v[i-1] + val;
		}
	}
	for(int i = one-1;i>0;i--) {
		int val = query(i + 1, i);
		if(v[i+1] + val > N) {
			v[i] = v[i+1] -val; 
		}
		else {
			v[i] = v[i-1] + val;
		}
	}
	for(int i = 1;i<=N;i++) {
		answer(i, v[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Incorrect 2 ms 200 KB Wrong Answer [1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Incorrect 2 ms 200 KB Wrong Answer [1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Incorrect 2 ms 200 KB Wrong Answer [1]
4 Halted 0 ms 0 KB -