QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56097 | #4884. Battleship: New Rules | Sorting# | WA | 3ms | 3704kb | C++ | 1.8kb | 2022-10-16 23:10:52 | 2022-10-16 23:10:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned char uc;
typedef long long ll;
#define fi first
#define se second
int n;
char c[2001][2001];
char ask(int x,int y){
cout << "? " << x << ' ' << y << endl;
int z;cin >> z;
if(z==1) return 'X';
else return '.';
}
void solve(int xl,int xr,int yl,int yr){
if(xr==xl+1 && yr==yl+1){
cout << "! " << xl*2 << ' ' << yl*2 << '\n';
return;
}
if(xr-xl>yr-yl){
int xm=(xl+xr)/2;
for(int i=xm*2-1; i<=xm*2 ;i++){
for(int j=yl*2-1; j<=yr ;j++){
if(c[i][j]=='?') c[i][j]=ask(i,j);
}
}
for(int k=yl; k<=yr ;k++){
if(c[xm*2-1][2*k-1]=='X' && c[xm*2-1][2*k]=='X'){
solve(xm,xr,yl,yr);
return;
}
if(c[xm*2][2*k-1]=='X' && c[xm*2][2*k]=='X'){
solve(xl,xm,yl,yr);
return;
}
}
if(c[xm*2-1][2*yl]=='X' || c[xm*2-1][2*yr-1]){
solve(xm,xr,yl,yr);
return;
}
else if(c[xm*2][2*yl]=='X' || c[xm*2][2*yr-1]){
solve(xl,xm,yl,yr);
return;
}
else while(true);
}
else{
int ym=(yl+yr)/2;
for(int i=xl*2-1; i<=xr*2 ;i++){
for(int j=ym*2-1; j<=ym ;j++){
if(c[i][j]=='?') c[i][j]=ask(i,j);
}
}
for(int k=xl; k<=xr ;k++){
if(c[2*k-1][ym*2-1]=='X' && c[2*k][ym*2-1]=='X'){
solve(xl,xr,ym,yr);
return;
}
if(c[2*k-1][ym*2]=='X' && c[2*k][ym*2]=='X'){
solve(xl,xr,yl,ym);
return;
}
}
if(c[2*xl][ym*2-1]=='X' || c[2*xr-1][ym*2-1]){
solve(xl,xr,ym,yr);
return;
}
else if(c[2*xl][ym*2]=='X' || c[2*xr-1][ym*2]){
solve(xl,xr,yl,ym);
return;
}
else while(true);
}
}
void solve(){
cin >> n;
if(n%2==1){
cout << "! -1 -1" << endl;
return;
}
for(int i=1; i<=n ;i++){
for(int j=1; j<=n ;j++){
c[i][j]='?';
}
}
solve(1,n/2,1,n/2);
}
int main(){
ios::sync_with_stdio(false);
int t;cin >> t;while(t--) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3704kb
input:
2 3 1 4 -1
output:
! -1 -1 ! -1 -1
result:
wrong output format Unexpected end of file - int32 expected (test case 2)