제출 #64090

#제출 시각아이디문제언어결과실행 시간메모리
64090baboWorm Worries (BOI18_worm)C++14
32 / 100
3 ms656 KiB
#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-4)
	{
		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){s,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();
	}
}

컴파일 시 표준 에러 (stderr) 메시지

worm.cpp: In function 'void dim1()':
worm.cpp:45:24: warning: unused variable 'i' [-Wunused-variable]
  L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
                        ^
worm.cpp:45:26: warning: unused variable 'ma' [-Wunused-variable]
  L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
                          ^~
worm.cpp:45:31: warning: unused variable 'mad' [-Wunused-variable]
  L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
                               ^~~
worm.cpp: In function 'long long int ask(long long int, long long int, long long int)':
worm.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&ret);
  ~~~~~^~~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:104:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld %lld",&n,&m,&k,&q); 
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...