QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185557#4884. Battleship: New RulesCrysflyWA 15ms4052kbC++201.6kb2023-09-22 11:43:062023-09-22 11:43:07

Judging History

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

  • [2023-09-22 11:43:07]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:4052kb
  • [2023-09-22 11:43:06]
  • 提交

answer

// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 400005
#define inf 0x3f3f3f3f

int n;
int vis[1005][1005];

int q(int x,int y){
	//cout<<"q "<<x<<" "<<y<<"\n";
	if(x<1||y<1||x>=n||y>=n)return 0;
	if(~vis[x][y])return vis[x][y];
	cout<<"? "<<x<<" "<<y<<endl;
	cin>>vis[x][y]; return vis[x][y];
}
int Q(int x,int y){
	For(i,0,1)For(j,0,1)if(q(x+i,y+j))return 1;
	return 0;
}

bool chk(int x1,int x2,int y1,int y2){
	int res=0;
	For(i,x1,x2)For(j,y1,y2)res|=(!Q(i,j));
	return res;
}

void solve(int x1,int x2,int y1,int y2){
//	cout<<"solve "<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<"\n";
	if(x1==x2&&y1==y2){
		cout<<"! "<<x1<<" "<<y1<<endl;
		return;
	}
	if(x2-x1>y2-y1){
		int mid=x1+x2>>1;
		if(chk(x1,mid,y1,y2))solve(x1,mid,y1,y2);
		else solve(mid+1,x2,y1,y2);
	}else{
		int mid=y1+y2>>1;
		if(chk(x1,x2,y1,mid))solve(x1,x2,y1,mid);
		else solve(x1,x2,mid+1,y2);
	}
}

void work()
{
	cin>>n;++n;
	For(i,0,n)For(j,0,n)vis[i][j]=-1;
	if(n%2==0){
		cout<<"! "<<-1<<" "<<-1<<endl;
		return;
	}
	solve(1,n,1,n);
}

signed main()
{
	int T;cin>>T;
	while(T--){
		work();
		int x;cin>>x;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
1
4
1
1
0
1
0
0
1
0
0
0
1
0
1
0
1
1

output:

! -1 -1
? 1 1
? 1 2
? 1 3
? 1 4
? 2 1
? 2 2
? 3 1
? 2 3
? 3 2
? 3 3
? 2 4
? 4 2
? 4 3
? 3 4
? 4 1
! 2 2

result:

ok max_C=3.75, avg_C=1.88 (2 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

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

output:

? 1 1
? 1 2
? 1 3
? 1 4
? 2 1
? 2 2
? 3 1
? 2 3
? 3 2
? 3 3
? 2 4
? 4 2
? 4 3
? 3 4
? 4 1
! 2 2
? 1 1
? 1 2
? 1 3
? 1 4
? 2 1
? 2 2
? 3 1
? 2 3
? 3 2
? 3 3
? 2 4
? 4 2
? 4 3
? 3 4
? 4 1
! 2 2
? 1 1
? 1 2
? 1 3
? 2 1
? 2 2
? 2 3
? 3 2
? 3 3
? 2 4
? 3 4
? 3 1
? 4 1
? 4 2
? 4 3
? 4 4
! 2 2
? 1 1
? 1 2
...

result:

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

Test #3:

score: -100
Wrong Answer
time: 15ms
memory: 4052kb

input:

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

output:

? 1 1
? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 2 1
? 2 2
? 2 3
? 3 2
? 3 3
? 2 4
? 2 5
? 3 4
? 2 6
? 3 5
? 3 6
? 2 7
? 3 1
? 4 1
? 4 2
? 4 3
? 5 2
? 5 3
? 4 4
? 5 4
? 4 5
? 4 6
? 5 1
? 6 1
? 6 2
? 5 5
? 5 6
? 6 3
? 6 4
? 6 5
? 6 6
? 7 1
? 7 2
? 8 1
? 7 3
? 8 2
? 7 4
? 8 3
? 7 5
? 8 4
? 7 6
? 8 5
? 7 7
? 8 6
...

result:

wrong output format Unexpected end of file - int32 expected (test case 1)