# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64088 | babo | Worm Worries (BOI18_worm) | C++14 | 3 ms | 588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define L long long
using namespace std;
L n,m,k,q;
L cnt;
const double distribution=2.61803398874;
struct S{
L x,y,z;
};
bool operator<(S a,S b){
if(a.x!=b.x) return a.x<b.x;
if(a.y!=b.y) return a.y<b.y;
return a.z<b.z;
}
map<S,L>mp;
L ask(L x,L y,L z){
if(mp[(S){x,y,z}]) return mp[(S){x,y,z}];
cnt++;
//printf("%lld\n",cnt);
printf("? %lld %lld %lld\n",x,y,z);
fflush(stdout);
L ret;
scanf("%lld",&ret);
//return mp[(S){x,y,z}]=10000000-(x>5?x-5:5-x);
if(ret==-1) exit(0);
else return mp[(S){x,y,z}]=ret;
}
void answer(S ans){
printf("! %lld %lld %lld\n",ans.x,ans.y,ans.z);
}
L hf(double x){
L ret=(L)x;
if(x-ret>0.5) ret++;
return ret;
}
void dim1(){
L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
while(s<e-2)
{
if(!mi1&&!mi2)
{
mi1=s+hf((e-s)/distribution);
mi2=e-hf((e-s)/distribution);
}
else if(!mi1)
{
mi1=s+hf((e-s)/distribution);
}
else if(!mi2)
{
mi2=e-hf((e-s)/distribution);
}
L lef=ask(mi1,1,1);
L rig=ask(mi2,1,1);
if(lef>rig)
{
e=mi2;
mi2=mi1;
mi1=0;
}
else
{
s=mi1;
mi1=mi2;
mi2=0;
}
}
while(s<e)
{
L mi1=(s+e)/2;
L mi2=mi1+1;
L lef=ask(mi1,1,1);
L rig=ask(mi2,1,1);
if(lef>rig)
{
e=mi1;
}
else
{
s=mi2;
}
}
answer((S){mad,1,1});
}
void dim2(){
}
void dim3(){
}
int main()
{
srand((int)time(NULL));
scanf("%lld %lld %lld %lld",&n,&m,&k,&q);
if(m==1&&k==1)
{
dim1();
}
else if(k==1)
{
dim2();
}
else
{
dim3();
}
}
Compilation message (stderr)
# | 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... |