제출 #703016

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
7030162023-02-25 15:05:28beepbeepsheepXylophone (JOI18_xylophone)C++17
0 / 100
1 ms208 KiB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
bool vis[5005];
int arr[5005];
void solve(int N) {
int l=1,r=N,m;
while (l!=r-1){
m=(l+r)>>1;
if (query(m,N)==N-1) l=m;
else r=m;
}
vis[1]=true;
arr[l]=1;
if (l==1){
arr[2]=query(l,l+1)+1;
for (int i=3;i<=N;i++){
int res=query(i-1,i);
if (arr[i-1]-res<1 || vis[arr[i-1]-res]){
arr[i]=res+arr[i-1];
vis[arr[i]]=true;
} else if (res+arr[i-1]>=N || vis[res+arr[i-1]]){
arr[i]=arr[i-1]-res;
vis[arr[i]]=true;
} else{
int res2=query(i-2,i);
if (res2==res){
arr[i]=arr[i-1]-res;
vis[arr[i]]=true;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...