QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#65774#4884. Battleship: New Rulesjapan022022#RE 7ms3292kbC++201.5kb2022-12-03 16:46:222022-12-03 16:46:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-03 16:46:25]
  • 评测
  • 测评结果:RE
  • 用时:7ms
  • 内存:3292kb
  • [2022-12-03 16:46:22]
  • 提交

answer

#include<iostream>
#include<cstdlib>
#include<cassert>
using namespace std;
bool ask(int x,int y)
{
	cout<<"? "<<x<<" "<<y<<endl;
	int r;cin>>r;
	if(r==-1)exit(0);
	return r==1;
}
void answer(int x,int y)
{
	cout<<"! "<<x<<" "<<y<<endl;
	int r;cin>>r;
	if(r==-1)exit(0);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;cin>>T;
	for(;T--;)
	{
		int N;
		cin>>N;
		if(N%2==1)
		{
			answer(-1,-1);
			continue;
		}
		int x=1,y=1;
		while(N>=6)
		{
			int f1,f2,f3,f4;
			//f1=ask(x,y)&&ask(x,y+N-3)&&ask(x+N-3,y+N-3)&&ask(x+N-3,y);
			f1=ask(x,y+N-3)&&ask(x+N-3,y+N-3)&&ask(x+N-3,y);
			//f2=ask(x,y+2)&&ask(x,y+N-1)&&ask(x+N-3,y+N-1)&&ask(x+N-3,y+2);
			f2=ask(x,y+2)&&ask(x+N-3,y+N-1)&&ask(x+N-3,y+2);
			//f3=ask(x+2,y)&&ask(x+2,y+N-3)&&ask(x+N-1,y+N-3)&&ask(x+N-1,y);
			f3=ask(x+2,y)&&ask(x+2,y+N-3)&&ask(x+N-1,y+N-3);
			//f4=ask(x+2,y+2)&&ask(x+2,y+N-1)&&ask(x+N-1,y+N-1)&&ask(x+N-1,y+2);
			f4=ask(x+2,y+2)&&ask(x+2,y+N-1)&&ask(x+N-1,y+2);
			if(f1&&f2&&f3&&f4)
			{
				x+=2;
				y+=2;
				N-=4;
			}
			else if(f1+f2+f3+f4==3)
			{
				if(!f1)x+=2,y+=2;
				else if(!f2)x+=2;
				else if(!f3)y+=2;
				N-=2;
			}
			else if(f1+f2+f3+f4==1)
			{
				if(f1);
				else if(f2)y+=2;
				else if(f3)x+=2;
				else x+=2,y+=2;
				N-=2;
			}
			else if(f1+f2+f3+f4==2)
			{
				if(f1);
				else if(f2)y+=2;
				else if(f3)x+=2;
				else x+=2,y+=2;
			}
			else assert(false);
		}
		assert(N==4);
		answer(x+1,y+1);
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3232kb

input:

2
3
1
4
1

output:

! -1 -1
! 2 2

result:

ok max_C=0.00, avg_C=0.00 (2 test cases)

Test #2:

score: 0
Accepted
time: 7ms
memory: 3292kb

input:

100
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
...

output:

! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
...

result:

ok max_C=0.00, avg_C=0.00 (100 test cases)

Test #3:

score: -100
Dangerous Syscalls

input:

100
10
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0

output:

? 1 8
? 8 8
? 8 1
? 1 3
? 8 10
? 8 3
? 3 1
? 3 8
? 10 8
? 3 3
? 3 10
? 10 3
? 3 6
? 6 6
? 6 3
? 3 5
? 5 3
? 5 5

result: