QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73468#4884. Battleship: New Rulesaurelion_solCompile Error//C++142.4kb2023-01-25 14:26:292023-01-25 14:26:30

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:26:30]
  • 评测
  • [2023-01-25 14:26:29]
  • 提交

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=8;
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){
		if(F){
			int x=u-1,y=l-1;
			sleep(x*1000);
		}
		put(u-1,l-1);
		return;
	}
	if(W==2)++F;
	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;
}

详细

answer.code: In function ‘void solve(int, int, int, int, vi, vi, vi, vi)’:
answer.code:37:25: error: ‘sleep’ was not declared in this scope
   37 |                         sleep(x*1000);
      |                         ^~~~~
answer.code: In function ‘int query(int, int)’:
answer.code:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         int z;scanf("%d",&z);
      |               ~~~~~^~~~~~~~~
answer.code: In function ‘void put(int, int)’:
answer.code:20:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         int z;scanf("%d",&z);
      |               ~~~~~^~~~~~~~~
answer.code: In function ‘void work()’:
answer.code:98:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   98 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:111:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  111 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~