이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ramen.h"
using namespace std;
void Ramen(int n) {
if (n == 1) {
Answer(0, 0);
return;
}
auto Ask = [&](int i, int j) {
return Compare(i, j);
};
vector<int> s;
for (int i = 0; i < n - n % 2; i += 2) {
s.push_back(Ask(i, i + 1));
}
int mn = 0, mx = 1;
if (s[0] == -1) {
swap(mn, mx);
}
for (int i = 1; i < (int) s.size(); i++) {
int x = 2 * i, y = 2 * i + 1;
if (s[i] == -1) {
swap(x, y);
}
if (Ask(x, mn) == 1) {
mn = x;
}
if (Ask(mx, y) == 1) {
mx = y;
}
}
if (n % 2 == 1) {
if (Ask(n - 1, mn) == 1) {
mn = n - 1;
}
if (Ask(mx, n - 1) == 1) {
mx = n - 1;
}
}
Answer(mx, mn);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |