QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387785#4884. Battleship: New RulesunputdownableWA 0ms3712kbC++171.1kb2024-04-12 20:17:532024-04-12 20:17:54

Judging History

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

  • [2024-04-12 20:17:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2024-04-12 20:17:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n,Ax,Ay,Bx,By;
inline void Answer(int x,int y) {
    cout<<"! "<<x<<' '<<y<<endl;
    int res; cin>>res;
    if(res==-1) exit(0);
}
inline int qry(int x,int y) {
    cout<<"? "<<x<<' '<<y<<endl;
    int res; cin>>res;
    return res;
}
inline void work() {
    cin>>n;
    if(n&1) return Answer(-1,-1),void();
    if(!qry(1,2)) {
        Ax=2;
        while(!qry(1,Ax+2)) Ax+=2;
        Bx=n-1;
        while(!qry(n,Bx-2)) Bx-=2;
        Ay=n-1;
        while(!qry(Ay-2,1)) Ay-=2;
        By=2;
        while(!qry(By+2,n)) By+=2;
        Answer(min(Ax,Bx),min(Ay,By));
    } else {
        Ax=2;
        while(!qry(n,Ax+2)) Ax+=2;
        Bx=n-1;
        while(!qry(1,Bx-2)) Bx-=2;
        Ay=n-1;
        while(!qry(Ay-2,n)) Ay-=2;
        By=2;
        while(!qry(By+2,1)) By+=2;
        Answer(min(Ax,Bx),min(Ay,By));
    }
}
signed main() {
    // freopen("localinput","r",stdin);
    // freopen("localoutput","w",stdout);
    int T; cin>>T;
    while(T--) work();
    // fprintf(stderr,"%.4lf\n",1.0*clock()/CLOCKS_PER_SEC);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3668kb

input:

2
3
1
4
1
1
1
1
1
1

output:

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

result:

ok max_C=1.25, avg_C=0.62 (2 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

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

output:

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

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb

input:

100
10
0
1
1
0
0
1
1
-1

output:

? 1 2
? 1 4
? 10 7
? 7 1
? 5 1
? 3 1
? 4 10
! 2 2

result:

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