이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
 
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 5005;
int two[maxn], three[maxn], a[maxn];
void solve(int N) 
{
	fo(i,1,N-1) two[i] = query(i, i+1);
	fo(i,1,N-2) three[i] = query(i, i+2);
	a[1] = 0; a[2] = two[1];
	int lastorder = 1;
	fo(i,1,N-2)
	{
		if(three[i] == two[i] + two[i+1])
		{
			a[i+2] = a[i+1] + lastorder * two[i+1];			
		}
		else
		{
			lastorder *= -1;
			a[i+2] = a[i+1] + lastorder * two[i+1];			
		}
	}
	int mn = inf, mx;
	// fo(i,1,N) pf("%d ", a[i]);
	fo(i,1,N) gmin(mn, a[i]);
	fo(i,1,N) a[i] -= mn - 1;
	mn = mx = -1;
	fo(i,1,N)
	{
		if(mn == -1 || a[mn] > a[i]) mn = i;
		if(mx == -1 || a[mx] < a[i]) mx = i;
	}
	if(mx < mn) fo(i,1,N) a[i] = N - a[i] + 1;
	fo(i,1,N) answer(i, a[i]);
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |