이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
template <class T>
using Vec = std::vector<T>;
int main() {
int N, M, K, Q;
std::cin >> N >> M >> K >> Q;
const auto query = [&](const int i, const int j, const int k) {
std::cout << "? " << i << ' ' << j << ' ' << k << std::endl;
int ret;
std::cin >> ret;
assert(ret != -1);
return ret;
};
const auto answer = [&](const int i, const int j, const int k) {
std::cout << "! " << i << ' ' << j << ' ' << k << std::endl;
std::exit(EXIT_SUCCESS);
};
if (M == 1 and K == 1) {
Vec<int> fib(2);
fib[0] = fib[1] = 1;
while (fib.back() < N + 1) {
const auto tmp = fib[fib.size() - 1] + fib[fib.size() - 2];
fib.push_back(tmp);
}
Vec<int> memo(N + 1);
const auto ask = [&](const int i) {
if (i > N) {
return N - i;
}
if (memo[i] == 0) {
memo[i] = query(i, 1, 1);
}
return memo[i];
};
int l = 0, r = N + 1, k = (int) fib.size() - 1;
while (r - l > 2) {
const auto m1 = r - fib[k - 1];
const auto m2 = l + fib[k - 1];
if (ask(m1) >= ask(m2)) {
r = m2;
}
else {
l = m1;
}
k -= 1;
}
answer(l + 1, 1, 1);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |