이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
static int A[5000];
int d[5000];
int V[5000];
void solve(int N) {
for(int i = 0; i<N-1; i++){
d[i] = query(i+1, i+2);
}
int dir =1;
for(int i = 0; i<N-2; i++){
int s = query(i+1, i+3);
if(s<abs(d[i]+d[i+1]*dir)){
dir*=-1;
}
d[i+1] = d[i+1]*dir;
}
V[0] = 0;
pii MIN = pii(0, 0);
pii MAX = pii(0, 0);
for(int i = 1; i<N; i++){
V[i] = V[i-1] + d[i-1];
if(MAX.first<V[i]){
MAX.first = V[i];
MAX.second = i;
}
else if(MIN.first>V[i]){
MIN.first = V[i];
MIN.second = i;
}
}
if(MAX.second<MIN.second){
for(int i = 0; i<N; i++){
V[i] = -V[i];
}
MIN.first = -MAX.first;
}
for(int i = 0; i<N; i++){
V[i]-=MIN.first;
}
for(int i = 0; i<N; i++){
answer(i+1, V[i]+1);
}
}
컴파일 시 표준 에러 (stderr) 메시지
xylophone.cpp:6:12: warning: 'A' defined but not used [-Wunused-variable]
6 | static int A[5000];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |