이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
const double C = 0.6180339;
int n, m, k, q;
int arr[N];
int query(int x){
if(arr[x]) return arr[x];
cout << "? " << x << " " << 1 << " " << 1 << "\n";
cout.flush();
cin >> arr[x];
return arr[x];
}
void answer(int x){
cout << "! " << x << " " << 1 << " " << 1 << "\n";
cout.flush();
exit(0);
}
int rand_except(int l, int r, int prev){
int t = rand() % (r - l + 1) + l;
if(t != prev) return t;
return rand_except(l, r, prev);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k >> q;
int l = 1, r = n, prev = rand() % n + 1;
while(l != r){
int nxt = rand_except(l, r, prev);
if(prev > nxt) swap(prev, nxt);
int a = query(prev), b = query(nxt);
if(a >= b){
r = nxt - 1;
}
else{
l = prev + 1;
prev = nxt;
}
}
answer(l);
}
# | 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... |