QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#55114 | #4884. Battleship: New Rules | Remocuz | TL | 3ms | 3792kb | C++20 | 1.8kb | 2022-10-12 11:51:32 | 2022-10-12 11:51:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
typedef pair<int,int> pii;
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
void work()
{
int n=read();
if(n%2==1)
{
printf("! -1 -1\n");
fflush(stdout);
if(read()!=1) exit(1);
}
else
{
auto chk=[&](int x,int y)
{
printf("? %d %d\n",x,y);
fflush(stdout);
if(read()==1) return 0;
printf("? %d %d\n",x+1,y);
fflush(stdout);
if(read()==1) return 0;
printf("? %d %d\n",x,y+1);
fflush(stdout);
if(read()==1) return 0;
printf("? %d %d\n",x+1,y+1);
fflush(stdout);
if(read()==1) return 0;
printf("! %d %d\n",x,y);
fflush(stdout);
return 1;
};
int l=1,r=n;
while(r-l>1)
{
if(chk(l+1,l+1))
{
if(read()!=1) exit(1);
return ;
}
if(chk(l+1,r-2))
{
if(read()!=1) exit(1);
return ;
}
if(chk(r-2,l+1))
{
if(read()!=1) exit(1);
return ;
}
if(chk(r-2,r-2))
{
if(read()!=1) exit(1);
return ;
}
}
printf("! -1 -1\n");
fflush(stdout);
if(read()!=1) exit(1);
}
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3688kb
input:
2 3 1 4 0 0 0 0 1
output:
! -1 -1 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2
result:
ok max_C=1.00, avg_C=0.50 (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
100 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 0 1 4 0 0 0 ...
output:
? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ? 2 2 ? 3 2 ? 2 3 ? 3 3 ! 2 2 ...
result:
ok max_C=1.00, avg_C=1.00 (100 test cases)
Test #3:
score: -100
Time Limit Exceeded
input:
100 10 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0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