# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
909622 | MilosMilutinovic | 라멘 (JOI14_ramen) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "ramen.h"
#include <atcoder/all>
using namespace std;
using namespace atcoder;
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);
}