답안 #763000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763000 2023-06-22T02:16:30 Z vjudge1 Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 208 KB
#include<bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int a[5001];

void ask(int x, int y, int z){
    int v1=abs(a[x]-a[y]), v2=query(min(y, z), max(y, z)), v3=query(min(x, z), max(x, z));
    if (v1!=v3 && v2!=v3){
        if (a[x]<a[y]){
            if (v1<v2) a[z]=a[x]-v1;
            else a[z]=a[y]+v2;
        }else{
            if (v1<v2) a[z]=a[x]+v1;
            else a[z]=a[y]-v2;
        }
    }else{
        if (a[x]<a[y]) a[z]=a[x]+v1;
        else a[z]=a[y]+v2;
    }
}

void solve(int N){
    int l=2, r=N;
    while (l<=r){
        int mid=(l+r)>>1ll;
        if (query(l, r)==N-1) r=mid-1;
        else l=mid+1;
    }
    a[l]=N;
    for (int i=l+1; i<=N; ++i){
        if (i==l+1) a[i]=N-query(l, l+1);
        else ask(i-2, i-1, i);
    }
    for (int i=l-1; i>=1; --i){
        if (i==l-1) a[i]=N-query(l-1, l);
        else ask(i+2, i+1, i);
    }
    for (int i=1; i<=N; ++i) answer(i, a[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -