Submission #1045496

# Submission time Handle Problem Language Result Execution time Memory
1045496 2024-08-06T03:26:05 Z tamir1 Xylophone (JOI18_xylophone) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
static int A[5000];

void solve(int N) {
	int l=1,r=N,mid,i,mx=1,idx=0;
	while(r>l){
		mid=(r+l+1)/2;
		if(query(mid,N)==N-1) l=mid;
		else r=mid-1;
	}
	answer(l,1);
	for(i=l+1;i<=N;i++){
		int x=query(l,i),y;
		if(x>=mx){
			answer(i,x+1);
			mx=x+1;
			idx=i;
		}
		else{
			y=query(idx,i);
			answer(i,mx-y);
		}
	}
	mx=1;
	idx=0;
	for(i=l-1;i>=1;i--){
		int x=query(i,l),y;
		if(x>=mx){
			answer(i,x+1);
			mx=x+1;
			idx=i;
		}
		else{
			y=query(i,idx);
			answer(i,mx-y);
		}
	}
}

Compilation message

xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -