# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
381059 | ritul_kr_singh | Xylophone (JOI18_xylophone) | C++17 | 1 ms | 364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include "bits/stdc++.h"
using namespace std;
// static int A[5000];
// int query(int i, int j){
// --i;
// return (*max_element(A+i, A+j) - *min_element(A+i, A+j));
// }
// void answer(int i, int j){ cout << j << ' '; }
void solve(int n){
int a[n][2];
a[0][0] = a[1][0] = 0;
a[0][1] = query(1, 2);
a[1][1] = -a[0][1];
for(int i=2; i<=n; ++i){
int res0 = query(i-2, i), res1 = query(i-1, i);
for(int j=0; j<2; ++j){
int x = a[j][i-3], y = a[j][i-2];
int &z = a[j][i-1];
if(x<y){
if(res1<=y-x){
z = res0 > y-x ? y + res1 : y - res1;
}else{
z = res0 > res1 ? y + res1 : y - res1;
}
}else{
if(res1<=x-y){
z = res0 > x-y ? y - res1 : y + res1;
}else{
z = res0 > res1 ? y - res1 : y + res1;
}
}
}
}
for(int j=0; j<2; ++j){
int add = *min_element(a[j], a[j]+n);
add = 1-add;
bool ok = true;
int leastPos, greatestPos, cnt[n];
for(int i=0; i<n; ++i) a[j][i] += add, cnt[i] = false;
for(int i=0; i<n and ok; ++i){
if(1<=a[j][i] and a[j][i]<=n and !cnt[a[j][i]-1]){
++cnt[a[j][i]-1];
}else ok = false;
if(a[j][i]==1) leastPos = i;
if(a[j][i]==n) greatestPos = i;
}
// ok = ok and (leastPos<greatestPos);
if(ok){
for(int i=0; i<n; ++i) answer(i+1, a[j][i]);
return;
}
}
}
// signed main(){
// int n; cin >> n;
// for(int i=0; i<n; ++i) cin >> A[i];
// solve(n);
// }
컴파일 시 표준 에러 (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... |