이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
int F(int n){
int l = 1, r = n, pos = 1;
while(l <= r){
int md = (l+r)>>1;
int x = query(md, n);
if (x != n-1) r = md - 1;
else{
pos = md;
l = md + 1;
}
}
return pos;
}
// void calc(int a, int b, int c){
// int x = query(a, c), y = query(b, c);
// }
void solve(int n){
int pos = F(n);
vector<int> a(n+1);
a[pos] = 1;
a[pos+1] = 1+query(pos, pos+1);
if (pos > 1) a[pos-1] = 1+query(pos-1, pos);
for (int i = pos-2; i >= 1; i--){
a[i] = a[i+1];
int x = query(i, i+1), y = query(i, i+2);
if (x == y){
if (a[i+1] > a[i+2]) a[i] -= x;
else a[i] += x;
}else{
if (a[i+1] > a[i+2]) a[i] += x;
else a[i] -= x;
}
}
for (int i = 1; i <= n; i++) answer(i, a[i]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |