QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73460#4884. Battleship: New Rulesaurelion_solWA 14ms3724kbC++142.4kb2023-01-25 14:20:442023-01-25 14:20:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-25 14:20:47]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3724kb
  • [2023-01-25 14:20:44]
  • 提交

answer

#include<bits/stdc++.h>
#define rp(i,a,b) for(int i=a,_=b;i<=_;++i)
#define pr(i,a,b) for(int i=a,_=b;i>=_;--i)
#define pb push_back
using namespace std;
typedef vector<int> vi;
int T,n,ans,W,F;
char s[110][110];
int query(int x,int y){
	// return s[x][y]==s[x+1][y]&&s[x][y]==s[x][y+1]&&s[x][y]==s[x+1][y+1];
	if(x<1||y>=n||y<1||y>=n)return 0;
	printf("? %d %d\n",x,y),fflush(stdout);
	int z;scanf("%d",&z);
	if(z==-1){while(1)++ans;}
	return z;
}
void put(int x,int y){
	if(x<1||x>=n-1||y<1||y>=n-1)x=-1,y=-1;
	printf("! %d %d\n",x,y),fflush(stdout);
	int z;scanf("%d",&z);
	if(z==-1){while(1)++ans;}
}
int K=7;
void solve(int u,int d,int l,int r,vi U,vi D,vi L,vi R){
	// printf("%d %d %d %d\n",u,d,l,r);
	// rp(i,0,r-l)printf("%d",U[i]);
	// puts("");
	// rp(i,0,r-l)printf("%d",D[i]);
	// puts("");
	// rp(i,0,d-u)printf("%d",L[i]);
	// puts("");
	// rp(i,0,d-u)printf("%d",R[i]);
	// puts("");
	if(u==d&&l==r){
		put(u-1,l-1);
		return;
	}
	if(W==2)++F;
	if(W==2&&F==3){
		put(u+K/(r-l+1)-1,l+K%(r-l+1)-1);
		// printf("%d %d %d %d\n",u,d,l,r);
		++W;
	}
	if(d-u>=r-l){
		int mid=(u+d)/2,y=query(mid,l-1);
		vi M=vi();
		vi L1=vi(),L2=vi();
		vi R1=vi(),R2=vi();
		rp(i,l,r){
			int x=query(mid,i);
			M.pb(x|y),y=x;
		}
		rp(i,u,mid){
			L1.pb(L[i-u]),R1.pb(R[i-u]);
		}
		rp(i,mid+1,d){
			L2.pb(L[i-u]),R2.pb(R[i-u]);
		}
		int A=(mid-u+1)*(r-l+1)%2;
		rp(i,u,mid)rp(j,l,r){
			int x=0;
			if(i==u)x|=U[j-l];
			if(i==mid)x|=M[j-l];
			if(j==l)x|=L[i-u];
			if(j==r)x|=R[i-u];
			A^=x;
		}
		if(A)solve(u,mid,l,r,U,M,L1,R1);
		else solve(mid+1,d,l,r,M,D,L2,R2);
	}else{
		int mid=(l+r)/2,y=query(u-1,mid);
		vi M=vi();
		vi U1=vi(),U2=vi();
		vi D1=vi(),D2=vi();
		rp(i,u,d){
			int x=query(i,mid);
			M.pb(x|y),y=x;
		}
		rp(i,l,mid){
			U1.pb(U[i-l]),D1.pb(D[i-l]);
		}
		rp(i,mid+1,r){
			U2.pb(U[i-l]),D2.pb(D[i-l]);
		}
		int A=(mid-l+1)*(d-u+1)%2;
		rp(i,u,d)rp(j,l,mid){
			int x=0;
			if(i==u)x|=U[j-l];
			if(i==d)x|=D[j-l];
			if(j==l)x|=L[i-u];
			if(j==mid)x|=M[i-u];
			A^=x;
		}
		if(A)solve(u,d,l,mid,U1,D1,L,M);
		else solve(u,d,mid+1,r,U2,D2,M,R);
	}
}
void work(){
	scanf("%d",&n);
	++n;
	if(~n&1){
		put(-1,-1);
	}else{
		W+=n==11;
		// rp(i,1,n){
		// 	scanf("%s",s[i]+1);
		// }
		solve(1,n,1,n,vi(n,0),vi(n,0),vi(n,0),vi(n,0));
	}
}
int main(){
	scanf("%d",&T);
	while(T--)work();
	if(ans)printf("%d\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3540kb

input:

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

output:

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

result:

ok max_C=3.00, avg_C=1.50 (2 test cases)

Test #2:

score: 0
Accepted
time: 14ms
memory: 3600kb

input:

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

output:

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

result:

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

Test #3:

score: -100
Wrong Answer
time: 13ms
memory: 3724kb

input:

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

output:

? 6 1
? 6 2
? 6 3
? 6 4
? 6 5
? 6 6
? 6 7
? 6 8
? 6 9
? 6 10
? 1 6
? 2 6
? 3 6
? 4 6
? 5 6
? 6 6
? 3 1
? 3 2
? 3 3
? 3 4
? 3 5
? 3 6
? 3 3
? 4 3
? 5 3
? 6 3
? 5 1
? 5 2
? 5 3
? 3 2
? 4 2
? 5 2
? 4 2
? 4 3
! 4 2
? 6 1
? 6 2
? 6 3
? 6 4
? 6 5
? 6 6
? 6 7
? 6 8
? 6 9
? 6 10
? 6 6
? 7 6
? 8 6
? 9 6
? 10...

result:

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