QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#384297 | #4884. Battleship: New Rules | zhoukangyang | RE | 0ms | 5648kb | C++14 | 1.9kb | 2024-04-09 21:29:28 | 2024-04-09 21:29:28 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
#define pb emplace_back
using namespace std;
#define i128 __int128
const int N = 2e3 + 7;
int n;
bool vis[N][N];
bool gr[N][N];
int query(int x, int y) {
cout << "? " << x << ' ' << y << endl;
// return gr[x][y];
int w;
cin >> w;
return w;
}
void report(int x, int y) {
cout << "! " << x << ' ' << y << endl;
int w;
cin >> w;
if(w == -1)assert(false);
}
void dc(int l1, int r1, int l2, int r2) {
if(l1 == r1 && l2 == r2) {
if(l1 == 0 || r1 == 0 || l2 == n || r2 == n) {
report(-1, -1);
} else {
report(l1, r1);
}
return;
}
if(r1 - l1 > r2 - l2) {
int m1 = (l1 + r1) >> 1;
L(j, l2 + 1, r2) if(l1 != r1) {
int u = query(m1 + 1, j);
if(u) vis[m1][j] = vis[m1][j - 1] = vis[m1 + 1][j] = vis[m1 + 1][j - 1] = 1;
}
int op = 0;
L(i, l1, m1) L(j, l2, r2)op ^= !vis[i][j];
if(op)dc(l1, m1, l2, r2);
else dc(m1 + 1, r1, l2, r2);
} else {
int m2 = (l2 + r2) >> 1;
L(j, l1 + 1, r1) if(l2 != r2) {
int u = query(j, m2 + 1);
if(u) vis[j][m2 + 1] = vis[j - 1][m2 + 1] = vis[j][m2] = vis[j - 1][m2] = 1;
}
int op = 0;
L(i, l1, r1) L(j, l2, m2)op ^= !vis[i][j];
if(op)dc(l1, r1, l2, m2);
else dc(l1, r1, m2 + 1, r2);
}
}
void Main() {
cin >> n;
if(n % 2 == 1) {
report(-1, -1);
return ;
}
L(i, 0, n) L(j, 0, n)vis[i][j] = 0;
dc(0, n, 0, n);
}
int main() {
gr[1][1] = 1;
gr[1][2] = 1;
gr[3][1] = 1;
gr[4][1] = 1;
gr[1][4] = 1;
gr[2][4] = 1;
gr[4][3] = 1;
gr[4][4] = 1;
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t; cin >> t; while(t--) Main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5632kb
input:
2 3 1 4 0 0 0 1 1 0 1 0 1
output:
! -1 -1 ? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 1 2 ? 2 2 ! 2 2
result:
ok max_C=2.00, avg_C=1.00 (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 5648kb
input:
100 4 0 0 0 1 1 0 1 0 1 4 0 0 0 1 1 0 1 0 1 4 1 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 4 0 0 0 1 1 0 1 0 1 4 0 0 0 1 1 0 1 0 1 4 0 0 0 1 1 0 1 0 1 4 1 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 4 0 0 0 1 1 0 1 0 1 4 1 0 0 0 0 0 0 0 1 4 0 0 0 1 1 0 1 0 1 4 0 0 0 1 1 0 1 ...
output:
? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 1 2 ? 2 2 ! 2 2 ? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 1 2 ? 2 2 ! 2 2 ? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 1 2 ? 2 2 ! 2 2 ? 1 3 ? 2 3 ? 3 3 ? 4 3 ? 3 1 ? 3 2 ? 1 2 ? 2 2 ! 2 2 ? 1 3 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