| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1350483 | Ghulam_Junaid | Xylophone (JOI18_xylophone) | C++20 | 13 ms | 492 KiB |
#include "xylophone.h"
// #include "grader.cpp"
void solve(int N) {
int a[N + 2], lo = 1, hi = N, mid, d, x, y;
while (hi - lo > 1) {
mid = (lo + hi) / 2;
if (query(mid, N) == N - 1) lo = mid;
else hi = mid;
}
a[lo] = 1;
bool done[N + 2] = {};
done[1] = 1;
for (int i = lo + 1; i <= N; i ++){
d = query(i - 1, i);
x = a[i - 1] + d, y = a[i - 1] - d;
if (x > N or done[x]) a[i] = y;
else if (y <= 0 or done[y]) a[i] = x;
else{
d = query(i - 2, i);
if (a[i - 2] < a[i - 1]){
if (d == x - a[i - 2])
a[i] = x;
else
a[i] = y;
}
else{
if (d == a[i - 2] - y)
a[i] = y;
else
a[i] = x;
}
}
done[a[i]] = 1;
}
for (int i = lo - 1; i > 0; i --){
d = query(i, i + 1);
x = a[i + 1] + d, y = a[i + 1] - d;
if (x > N or done[x]) a[i] = y;
else if (y <= 0 or done[y]) a[i] = x;
else{
d = query(i, i + 2);
if (a[i + 2] < a[i + 1]){
if (d == x - a[i + 2])
a[i] = x;
else
a[i] = y;
}
else{
if (d == a[i + 2] - y)
a[i] = y;
else
a[i] = x;
}
}
done[a[i]] = 1;
}
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... | ||||
