이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
void solve(int n) {
	// int value = query(1, N);
	// for(int i = 1; i <= N; i++) {
	// 	answer(i, i);
	// }
    int arr[n];
    int barr[n];
    int dir[n];
    for(int i=0; i<n-1; i++){
        arr[i]=query(i+1, i+2);
    }
    for(int i=0; i<n-2; i++){
        barr[i]=query(i+1, i+3);
    }
    dir[0]=1;
    for(int i=0; i<n-2; i++){
        if(barr[i]==max(arr[i], arr[i+1])){
            dir[i+1]=-dir[i];
        }
        else{
            dir[i+1]=dir[i];
        }
    }
    int ans[n];
    ans[0]=0;
    for(int i=1; i<n; i++){
        ans[i]=ans[i-1]+arr[i-1]*dir[i-1];
    }
    int minn = 1000000;
    for(int i=0; i<n; i++){
        minn = min(minn, ans[i]);
    }
    for(int i=0; i<n; i++){
        ans[i]+=minn+1;
    }
    bool res = false;
    for(int i=0; i<n; i++){
        if(ans[i]==n){
            res = true;
            break;
        }
        else if(ans[i]==1){
            break;
        }
    }
    if(res==true){
        for(int i=0; i<n; i++){
            ans[i] = n+1-ans[i];
        }
    }
    for(int i=0; i<n; i++){
        answer(i+1, ans[i]);
    }
    return;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |