# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
58556 | gusfring | Xylophone (JOI18_xylophone) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
int A[MAXN], dif[MAXN];
void solve(int N){
for(int i=1; i<N; ++i) dif[i - 1] = query(i, i + 1);
int sign = 1;
A[0] = 0, A[1] = dif[0];
for(int i=1; i<N-1; ++i){
if(query(i, i + 2) != (dif[i - 1] + dif[i])) sign = -sign;
A[i + 1] = A[i] + sign * dif[i];
}
int mn = 0, mx = 0;
for(int i=1; i<N; ++i){
if(A[i] < A[mn]) mn = i;
if(A[i] > A[mx]) mx = i;
}
if(mn > mx){
for(int i=1; i<N; ++i) A[i] = -A[i];
swap(mn, mx);
}
for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1);
}