QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73755 | #4884. Battleship: New Rules | Appleblue17 | WA | 19ms | 3496kb | C++14 | 884b | 2023-01-27 21:46:32 | 2023-01-27 21:46:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int T,n;
void solve(int l,int r,int L,int R,bool typ){
if(l==r && L==R){
if(typ) swap(l,L);
cout<<"! "<<l-1<<" "<<L-1<<'\n';
int s; cin>>s;
return ;
}
if(R-L<r-l){
solve(L,R,l,r,typ^1);
return ;
}
int MID=(L+R)>>1;
int tot=0,lst=0;
if(l-1>=1){
if(!typ) cout<<"? "<<l-1<<" "<<MID<<'\n';
else cout<<"? "<<MID<<" "<<l-1<<'\n';
cin>>lst;
}
for(int i=l;i<r;i++){
if(!typ) cout<<"? "<<i<<" "<<MID<<'\n';
else cout<<"? "<<MID<<" "<<i<<'\n';
int s; cin>>s;
if(s || lst) tot++;
lst=s;
}
if(lst) tot++;
if(((r-l+1)*(MID-L+1)%2)^(tot%2)) solve(l,r,L,MID,typ);
else solve(l,r,MID+1,R,typ);
}
int main(){
cin>>T;
while(T--){
cin>>n;
if(n & 1){
cout<<"! -1 -1"<<'\n';
int s; cin>>s;
continue;
}
solve(1,n+1,1,n+1,0);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3304kb
input:
2 3 1 4 0 0 0 1 1 0 0 0 0 1
output:
! -1 -1 ? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 2 1 ? 2 2 ? 2 2 ! 2 2
result:
ok max_C=2.25, avg_C=1.12 (2 test cases)
Test #2:
score: 0
Accepted
time: 19ms
memory: 3496kb
input:
100 4 0 0 0 1 1 0 0 0 0 1 4 0 0 0 1 1 0 0 0 0 1 4 1 0 0 0 0 0 1 0 0 1 4 1 0 0 0 0 0 1 0 0 1 4 0 0 0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