이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = 2e9;
int ask(int n, int m = 1, int k = 1) {
int ans;
cout << "? " << n << ' ' << m << ' ' << k << endl;
cin >> ans;
return ans;
}
void out(int n, int m = 1, int k = 1) {
cout << "! " << n << ' ' << m << ' ' << k << endl;
::exit(0);
}
void solve() {
int n, m, k, q;
cin >> n >> m >> k >> q;
if (max(m, k) == 1) {
int lx = 1, rx = n;
vector<int> ans(n + 2, -1);
ans[1] = ask(1);
ans[0] = ans[n + 1] = 0;
while (rx - lx > 3) {
int mid = (lx + rx) >> 1;
if (ans[mid] == -1)
ans[mid] = ask(mid);
if (ans[mid] - ans[lx] < mid - lx) {
rx = mid;
} else {
lx = mid;
}
}
for (int i = max(1, lx - 1); i <= min(n, rx + 1); i++) {
if (ans[i] == -1)
ans[i] = ask(i);
}
for (int i = 1; i <= n; i++) {
if (min(ans[i - 1], min(ans[i], ans[i + 1])) != -1) {
if (max(ans[i - 1], ans[i + 1]) <= ans[i]) {
out(i);
}
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cout.tie(nullptr);
cin.tie(nullptr);
int queries = 1;
#ifdef test_cases
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
// cin >> queries;
#else
// cin >> queries;
#endif
for (int test_case = 1; test_case <= queries; test_case++) {
solve();
// cout << '\n';
}
}
# | 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... |