QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770291#4884. Battleship: New RulesI_be_wannaCompile Error//C++142.8kb2024-11-21 21:22:252024-11-21 21:22:25

Judging History

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

  • [2024-11-21 21:22:25]
  • 评测
  • [2024-11-21 21:22:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define MAXN 1010
using namespace std;
int T,n,a[MAXN][MAXN];
int query(int x,int y){
	printf("? %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w;
}
bool check(int x,int y){
	printf("! %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w==1;
}
void solve(int xl,int xr,int yl,int yr){//cerr<<"solve:"<<xl<<' '<<xr<<' '<<yl<<' '<<yr<<endl;
	if(xl==xr&&yl==yr){assert(check(xl-1,yl-1));return;}
	if(xr-xl>yr-yl){
		int mid=(xl+xr)>>1;
		for(int i=yl;i<yr;i++){
			int now=query(mid,i);
			a[mid][i]|=now;a[mid+1][i]|=now;
			a[mid][i+1]|=now;a[mid+1][i+1]|=now;
		}
		int ls=0;//cerr<<'['<<xl<<','<<mid<<']'<<','<<'['<<yl<<','<<yr<<']'<<endl;
		for(int i=xl;i<=mid;i++)
			for(int j=yl;j<=yr;j++)ls^=(!a[i][j]);
	/*	for(int i=1;i<=n+1;i++){
			for(int j=1;j<=n+1;j++)cerr<<a[i][j]<<' ';
			cerr<<endl;
		}*/
		if(ls)solve(xl,mid,yl,yr);
		else solve(mid+1,xr,yl,yr);
	}else{
		int mid=(yl+yr)>>1;
		for(int i=xl;i<xr;i++){
			int now=query(i,mid);
			a[i][mid]|=now;a[i+1][mid]|=now;
			a[i][mid+1]|=now;a[i+1][mid+1]|=now;
		}
		int ls=0;//cerr<<'['<<xl<<','<<xr<<']'<<','<<'['<<yl<<','<<mid<<']'<<endl;
		for(int i=xl;i<=xr;i++)
			for(int j=yl;j<=mid;j++)ls^=(!a[i][j]);
	/*	for(int i=1;i<=n+1;i++){
			for(int j=1;j<=n+1;j++)cerr<<a[i][j]<<' ';
			cerr<<endl;
		}*/
		if(ls)solve(xl,xr,yl,mid);
		else solve(xl,xr,mid+1,yr);
	}
}
signed main(){
	scanf("%lld",&T);
	while(T--){
		scanf("%lld",&n);
		for(int i=1;i<=n+1;i++)
			for(int j=1;j<=n+1;j++)a[i][j]=0;
		if(n&1){assert(check(-1,-1));continue;}
		solve(1,n+1,1,n+1);
	}
	return 0;
}
/*#include<bits/stdc++.h>
#define int long long
#define MAXN 1010
using namespace std;
int T,n,a[MAXN][MAXN];
int query(int x,int y){
	printf("? %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w;
}
bool check(int x,int y){
	printf("! %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w==1;
}
void solve(int xl,int xr,int yl,int yr){//cerr<<"solve:"<<xl<<' '<<xr<<' '<<yl<<' '<<yr<<endl;
	if(xl==xr&&yl==yr){assert(check(xl-1,yl-1));return;}
	if(xr-xl>yr-yl){
		int mid=(xl+xr)>>1;
		for(int i=yl;i<yr;i++){
			int now=query(mid,i);
			a[mid][i]|=now;a[mid+1][i]|=now;
			a[mid][i+1]|=now;a[mid+1][i+1]|=now;
		}
		int ls=0;//cerr<<'['<<xl<<','<<mid<<']'<<','<<'['<<yl<<','<<yr<<']'<<endl;
		for(int i=xl;i<=mid;i++)
			for(int j=yl;j<=yr;j++)ls^=(!a[i][j]);
	/*	for(int i=1;i<=n+1;i++){
			for(int j=1;j<=n+1;j++)cerr<<a[i][j]<<' ';
			cerr<<endl;
		}*/
		if(ls)solve(xl,mid,yl,yr);
		else solve(mid+1,xr,yl,yr);
	}else{
		int mid=(yl+yr)>>1;
		for(int i=xl;i<xr;i++){
			int now=query(i,mid);
			a[i][mid]|=now;a[i+1][mid]|=now;
			a[i][mid+1]|=now;a[i+1][mid+1]|=now;
	}
	return 0;
}*/

詳細信息

answer.code:90:17: error: expected unqualified-id before ‘if’
   90 |                 if(ls)solve(xl,mid,yl,yr);
      |                 ^~
answer.code:91:17: error: expected unqualified-id before ‘else’
   91 |                 else solve(mid+1,xr,yl,yr);
      |                 ^~~~
answer.code:92:9: error: expected declaration before ‘}’ token
   92 |         }else{
      |         ^
answer.code:92:10: error: expected unqualified-id before ‘else’
   92 |         }else{
      |          ^~~~
answer.code:100:3: error: expected unqualified-id before ‘/’ token
  100 | }*/
      |   ^
answer.code: In function ‘long long int query(long long int, long long int)’:
answer.code:8:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         int w;scanf("%lld",&w);return w;
      |               ~~~~~^~~~~~~~~~~
answer.code: In function ‘bool check(long long int, long long int)’:
answer.code:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         int w;scanf("%lld",&w);return w==1;
      |               ~~~~~^~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:51:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         scanf("%lld",&T);
      |         ~~~~~^~~~~~~~~~~
answer.code:53:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |                 scanf("%lld",&n);
      |                 ~~~~~^~~~~~~~~~~