이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int arr[5005];
void solve(int n) {
arr[1]=0;
arr[2]=query(1,2);
int temp1,temp2;
for (int x=3;x<=n;x++){
temp1=query(x-2,x);
temp2=query(x-1,x);
arr[x]=arr[x-1]+temp2;
if (max(arr[x],max(arr[x-1],arr[x-2]))-min(arr[x],min(arr[x-1],arr[x-2]))!=temp1){
arr[x]=arr[x-1]-temp2;
}
}
int __min=1000000;
for (int x=1;x<=n;x++) __min=min(__min,arr[x]);
for (int x=1;x<=n;x++) arr[x]-=__min-1;
int lo,hi;
for (int x=1;x<=n;x++){
if (arr[x]==1) lo=x;
if (arr[x]==n) hi=x;
}
if (lo>hi)
for (int x=1;x<=n;x++) arr[x]=n-arr[x]+1;
for (int x=1;x<=n;x++) answer(x,arr[x]);
}
컴파일 시 표준 에러 (stderr) 메시지
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:33:2: warning: 'hi' may be used uninitialized in this function [-Wmaybe-uninitialized]
33 | if (lo>hi)
| ^~
xylophone.cpp:33:2: warning: 'lo' may be used uninitialized in this function [-Wmaybe-uninitialized]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |