이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 1000000
lli n,m,k,q,res,x;
double phi = (1+sqrt(5))/2;
lli query(lli pos) {
if (pos > n || pos == 0) return 0;
cout << "? " << pos << " 1 1" << endl;
lli a;
cin >> a;
if (a == -1) exit(0);
return a;
}
lli gold(lli ini, lli fin){
lli val = ini + (fin-ini+1)/phi;
return val;
}
lli busca(lli ini, lli fin, lli x, lli vx) {
if (ini==fin) return x;
lli y = gold(ini,fin);
if (2*x > ini+fin) y = (ini+fin) - y;
if (x == y) y++;
lli vy = query(y);
if (x > y) {swap(x,y); swap(vx,vy);}
if (vx >= vy) return busca(ini,y-1,x,vx);
else return busca(x+1,fin,y,vy);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k >> q;
res = 0;
x = gold(1,n);
res = busca(1,n,x,query(x));
cout << "! " << res << " 1 1";
}
# | 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... |