제출 #397400

#제출 시각아이디문제언어결과실행 시간메모리
397400KoDWorm Worries (BOI18_worm)C++17
32 / 100
6 ms4168 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...