# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
874425 | AlphaMale06 | Xylophone (JOI18_xylophone) | C++14 | 52 ms | 592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int n){
int a[n+1]={0};
int q1[n-1];
int q2[n-2];
for(int i=0; i<n-1; i++){
q1[i]=query(i+1, i+2);
}
for(int i=0; i< n-2; i++){
q2[i]=query(i+1, i+3);
}
a[1]=1;
a[2]=1+q1[0];
int mn=1;
for(int i=3; i<=n; i++){
int pos1=a[i-1]+q1[i-2];
int pos2=a[i-1]-q1[i-2];
if(q1[i-2]==q2[i-3] || q2[i-3]==abs(a[i-2]-a[i-1])){
if(a[i-1]>a[i-2])a[i]=pos2;
else a[i]=pos1;
}
else{
if(a[i-1]>a[i-2])a[i]=pos1;
else a[i]=pos2;
}
mn=min(mn ,a[i]);
}
mn--;
int psn=0;
int ps1=0;
int b[n+1];
for(int i=1; i<=n; i++){
a[i]-=mn;
if(a[i]==1)ps1=i;
if(a[i]==n)psn=i;
}
if(ps1>=psn){
a[1]=1;
a[2]=1-q1[0];
mn=a[2];
for(int i=3; i<=n; i++){
int pos1=a[i-1]+q1[i-2];
int pos2=a[i-1]-q1[i-2];
if(q1[i-2]==q2[i-3] || q2[i-3]==abs(a[i-2]-a[i-1])){
if(a[i-1]>a[i-2])a[i]=pos2;
else a[i]=pos1;
}
else{
if(a[i-1]>a[i-2])a[i]=pos1;
else a[i]=pos2;
}
mn=min(mn ,a[i]);
}
mn--;
for(int i=1; i<=n; i++){
a[i]-=mn;
}
}
for(int i=1; i<=n; i++){
answer(i, a[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |