QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#253360 | #4575. Interactive Treasure Hunt | LaStataleBlue# | AC ✓ | 4ms | 3684kb | C++20 | 1.7kb | 2023-11-16 22:03:56 | 2023-11-16 22:03:57 |
Judging History
answer
#pragma ide diagnostic ignored "misc-no-recursion"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef double db;
#define TESTCASE 1
#define LOCAL_INTERACTOR 0
static constexpr int INF = 1e9;
#if LOCAL_INTERACTOR
static pair<int, int> A = {1, 42};
static pair<int, int> B = {2, 69};
#endif
static int scan(int x, int y) {
cout << "SCAN " << (x + 1) << ' ' << (y + 1) << endl;
#if LOCAL_INTERACTOR
return abs(x + 1 - A.first) + abs(y + 1 - A.second) + abs(x + 1 - B.first) + abs(y + 1 - B.second);
#endif
int d;
cin >> d;
return d;
}
bool dig(int x, int y) {
cout << "DIG " << (x + 1) << ' ' << (y + 1) << endl;
#if LOCAL_INTERACTOR
return A == pair{x + 1, y + 1} || B == pair{x + 1, y + 1};
#endif
int d;
cin >> d;
return d;
}
static void solve([[maybe_unused]] int tc) {
int N, M;
cin >> N >> M;
int q1 = scan(0, 0);
int q2 = scan(0, M - 1);
int xs = (q1 + q2 - 2 * (M - 1)) / 2;
int ys = (q1 - q2 + 2 * (M - 1)) / 2;
int q3 = scan(xs / 2, 0);
int q4 = scan(0, ys / 2);
int xd = q3 - ys;
int yd = q4 - xs;
int x1 = (xs + xd) / 2;
int x2 = (xs - xd) / 2;
int y1 = (ys + yd) / 2;
int y2 = (ys - yd) / 2;
if (dig(x1, y1)) {
dig(x2, y2);
} else {
dig(x2, y1);
dig(x1, y2);
}
}
int main() {
ios::sync_with_stdio(false);
if (const char *f = getenv("REDIRECT_STDOUT"); f) {
freopen(f, "w", stdout);
}
int T = 1;
#if TESTCASE
cin >> T;
#endif
for (int t = 1; t <= T; t++) {
solve(t);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
1 2 3 3 1 3 1 1 1
output:
SCAN 1 1 SCAN 1 3 SCAN 1 1 SCAN 1 2 DIG 1 3 DIG 1 2
result:
ok (1 test case)
Test #2:
score: 0
Accepted
time: 4ms
memory: 3548kb
input:
72 3 3 1 5 1 1 1 1 3 3 4 4 4 4 0 1 1 3 3 5 5 3 5 0 1 1 3 2 2 4 2 2 1 1 3 3 5 1 5 1 1 1 3 2 3 3 3 3 1 1 3 3 4 4 4 2 1 1 2 3 3 3 3 3 1 1 3 3 3 5 1 3 1 1 3 3 1 3 1 1 1 1 3 3 3 3 3 3 0 1 1 2 3 3 3 3 3 0 1 1 3 2 1 1 1 1 1 1 3 2 4 4 2 4 1 1 2 3 3 3 3 1 1 1 3 3 4 2 4 2 0 1 1 2 3 3 1 3 1 1 1 3 3 2 4 2 2 0 1...
output:
SCAN 1 1 SCAN 1 3 SCAN 1 1 SCAN 1 1 DIG 2 1 DIG 1 1 SCAN 1 1 SCAN 1 3 SCAN 2 1 SCAN 1 2 DIG 3 3 DIG 1 3 DIG 3 1 SCAN 1 1 SCAN 1 3 SCAN 2 1 SCAN 1 2 DIG 3 3 DIG 2 3 DIG 3 1 SCAN 1 1 SCAN 1 2 SCAN 2 1 SCAN 1 1 DIG 3 1 DIG 1 1 SCAN 1 1 SCAN 1 3 SCAN 1 1 SCAN 1 3 DIG 2 3 DIG 1 3 SCAN 1 1 SCAN 1 2 SCAN 2...
result:
ok (72 test cases)
Test #3:
score: 0
Accepted
time: 4ms
memory: 3612kb
input:
100 2 16 15 17 15 15 0 1 1 2 4 6 2 6 2 0 1 1 2 15 18 12 18 2 1 1 2 5 3 9 1 3 1 1 2 13 14 14 12 14 1 1 2 15 16 14 16 14 0 1 1 2 5 7 3 7 1 1 1 2 6 6 6 6 6 0 1 1 2 4 2 4 2 2 1 1 2 16 20 12 20 12 1 1 2 13 17 11 15 11 1 1 2 8 8 8 8 8 0 1 1 2 12 10 12 10 8 1 1 2 12 15 11 13 11 1 1 2 12 1 21 1 1 1 1 2 15 1...
output:
SCAN 1 1 SCAN 1 16 SCAN 1 1 SCAN 1 8 DIG 2 15 DIG 1 15 DIG 2 1 SCAN 1 1 SCAN 1 4 SCAN 1 1 SCAN 1 3 DIG 2 4 DIG 1 4 DIG 2 3 SCAN 1 1 SCAN 1 15 SCAN 1 1 SCAN 1 9 DIG 2 10 DIG 1 9 SCAN 1 1 SCAN 1 5 SCAN 2 1 SCAN 1 1 DIG 2 2 DIG 2 1 SCAN 1 1 SCAN 1 13 SCAN 2 1 SCAN 1 7 DIG 2 13 DIG 2 1 SCAN 1 1 SCAN 1 1...
result:
ok (100 test cases)
Test #4:
score: 0
Accepted
time: 3ms
memory: 3632kb
input:
100 7 2 6 4 4 4 1 1 10 2 17 15 3 15 1 1 12 2 9 11 7 9 1 1 6 2 11 11 1 11 1 1 14 2 16 14 12 14 1 1 7 2 7 7 7 7 1 1 16 2 21 19 9 19 1 1 13 2 8 8 4 8 1 1 15 2 8 10 4 8 1 1 9 2 6 6 6 6 0 1 1 11 2 15 13 3 13 1 1 13 2 13 11 7 11 1 1 15 2 18 18 6 18 1 1 5 2 5 7 1 5 1 1 8 2 7 7 3 7 0 1 1 11 2 8 6 6 6 1 1 14...
output:
SCAN 1 1 SCAN 1 2 SCAN 3 1 SCAN 1 2 DIG 4 2 DIG 2 2 SCAN 1 1 SCAN 1 2 SCAN 8 1 SCAN 1 2 DIG 9 2 DIG 8 2 SCAN 1 1 SCAN 1 2 SCAN 5 1 SCAN 1 1 DIG 9 1 DIG 2 1 SCAN 1 1 SCAN 1 2 SCAN 6 1 SCAN 1 1 DIG 6 2 DIG 6 1 SCAN 1 1 SCAN 1 2 SCAN 8 1 SCAN 1 2 DIG 13 2 DIG 3 2 SCAN 1 1 SCAN 1 2 SCAN 4 1 SCAN 1 1 DIG...
result:
ok (100 test cases)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
100 3 10 11 15 7 9 1 1 3 12 22 4 22 4 0 1 1 3 13 20 12 16 8 1 1 3 4 6 6 4 6 1 1 3 10 9 13 9 5 0 1 1 3 15 20 10 20 6 1 1 3 13 16 10 16 4 1 1 3 16 13 23 11 3 1 1 3 12 7 15 7 1 1 1 3 8 7 13 5 3 1 1 3 13 17 13 15 13 1 1 3 9 10 10 8 4 1 1 3 9 6 14 6 4 0 1 1 3 11 11 13 11 11 0 1 1 3 4 2 8 2 2 1 1 3 7 13 7...
output:
SCAN 1 1 SCAN 1 10 SCAN 3 1 SCAN 1 4 DIG 3 7 DIG 3 2 SCAN 1 1 SCAN 1 12 SCAN 2 1 SCAN 1 11 DIG 3 12 DIG 1 12 DIG 3 10 SCAN 1 1 SCAN 1 13 SCAN 3 1 SCAN 1 9 DIG 3 11 DIG 3 7 SCAN 1 1 SCAN 1 4 SCAN 2 1 SCAN 1 2 DIG 3 4 DIG 2 1 SCAN 1 1 SCAN 1 10 SCAN 2 1 SCAN 1 4 DIG 3 6 DIG 1 6 DIG 3 3 SCAN 1 1 SCAN 1...
result:
ok (100 test cases)
Test #6:
score: 0
Accepted
time: 4ms
memory: 3684kb
input:
100 7 3 10 14 2 10 1 1 5 3 6 4 6 4 0 1 1 5 3 6 10 2 6 1 1 6 3 9 9 3 9 1 1 6 3 7 3 7 3 1 1 10 3 11 11 7 11 1 1 15 3 31 29 3 29 1 1 16 3 12 10 12 10 0 1 1 11 3 9 9 7 9 1 1 15 3 27 23 7 23 1 1 6 3 6 8 6 6 1 1 12 3 18 14 12 14 1 1 4 3 3 7 1 3 1 1 14 3 18 16 12 16 0 1 1 8 3 11 11 3 9 1 1 16 3 11 13 3 11 ...
output:
SCAN 1 1 SCAN 1 3 SCAN 6 1 SCAN 1 1 DIG 7 1 DIG 5 1 SCAN 1 1 SCAN 1 3 SCAN 2 1 SCAN 1 2 DIG 4 3 DIG 1 3 DIG 4 2 SCAN 1 1 SCAN 1 3 SCAN 4 1 SCAN 1 1 DIG 5 1 DIG 3 1 SCAN 1 1 SCAN 1 3 SCAN 4 1 SCAN 1 2 DIG 5 3 DIG 4 1 SCAN 1 1 SCAN 1 3 SCAN 2 1 SCAN 1 3 DIG 4 3 DIG 1 3 SCAN 1 1 SCAN 1 3 SCAN 5 1 SCAN ...
result:
ok (100 test cases)
Test #7:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
100 10 6 15 15 5 11 1 1 4 8 1 13 1 1 1 1 2 2 1 1 1 1 1 1 15 6 10 6 10 6 0 1 1 7 4 3 7 3 3 1 1 4 4 7 9 3 7 0 1 1 12 10 26 26 12 20 1 1 11 3 8 10 8 8 1 1 6 11 16 14 12 8 0 1 1 3 11 17 9 15 9 0 1 1 7 8 12 14 10 10 1 1 16 12 16 20 14 12 0 1 1 15 11 19 17 19 9 1 1 16 9 16 20 6 12 1 1 4 16 6 28 6 6 1 1 8 ...
output:
SCAN 1 1 SCAN 1 6 SCAN 6 1 SCAN 1 3 DIG 6 4 DIG 6 3 SCAN 1 1 SCAN 1 8 SCAN 1 1 SCAN 1 1 DIG 1 2 DIG 1 1 SCAN 1 1 SCAN 1 2 SCAN 1 1 SCAN 1 1 DIG 1 2 DIG 1 1 SCAN 1 1 SCAN 1 6 SCAN 2 1 SCAN 1 4 DIG 4 6 DIG 1 6 DIG 4 3 SCAN 1 1 SCAN 1 4 SCAN 2 1 SCAN 1 1 DIG 3 2 DIG 1 1 SCAN 1 1 SCAN 1 4 SCAN 3 1 SCAN ...
result:
ok (100 test cases)
Test #8:
score: 0
Accepted
time: 3ms
memory: 3680kb
input:
100 11 15 20 12 20 10 0 1 1 15 11 10 30 10 10 1 1 16 13 15 17 13 9 1 1 11 16 30 26 24 22 1 1 10 12 21 31 7 17 1 1 15 11 21 33 15 19 0 1 1 13 13 31 31 15 27 0 1 1 15 14 19 33 11 13 1 1 14 10 34 36 8 30 1 1 14 15 23 19 17 13 0 1 1 11 13 25 21 23 17 0 1 1 14 15 35 35 19 31 1 1 15 15 27 27 23 19 0 1 1 1...
output:
SCAN 1 1 SCAN 1 15 SCAN 2 1 SCAN 1 10 DIG 3 14 DIG 1 14 DIG 3 6 SCAN 1 1 SCAN 1 11 SCAN 6 1 SCAN 1 1 DIG 11 1 DIG 1 1 SCAN 1 1 SCAN 1 13 SCAN 3 1 SCAN 1 6 DIG 4 9 DIG 2 4 SCAN 1 1 SCAN 1 16 SCAN 7 1 SCAN 1 9 DIG 11 14 DIG 4 5 SCAN 1 1 SCAN 1 12 SCAN 8 1 SCAN 1 4 DIG 9 5 DIG 8 3 SCAN 1 1 SCAN 1 11 SC...
result:
ok (100 test cases)
Test #9:
score: 0
Accepted
time: 4ms
memory: 3552kb
input:
100 16 16 34 38 16 22 1 1 16 16 34 24 34 22 1 1 16 16 28 22 28 18 1 1 16 16 17 27 11 17 1 1 16 16 34 30 30 26 0 1 1 16 16 29 21 25 19 1 1 16 16 36 28 24 22 0 1 1 16 16 43 15 35 15 1 1 16 16 36 40 18 26 0 1 1 16 16 38 36 22 26 1 1 16 16 21 27 15 13 1 1 16 16 24 32 14 20 1 1 16 16 41 31 25 25 0 1 1 16...
output:
SCAN 1 1 SCAN 1 16 SCAN 11 1 SCAN 1 7 DIG 13 8 DIG 10 7 SCAN 1 1 SCAN 1 16 SCAN 8 1 SCAN 1 11 DIG 15 15 DIG 1 7 SCAN 1 1 SCAN 1 16 SCAN 6 1 SCAN 1 10 DIG 11 14 DIG 1 6 SCAN 1 1 SCAN 1 16 SCAN 4 1 SCAN 1 6 DIG 5 11 DIG 4 1 SCAN 1 1 SCAN 1 16 SCAN 9 1 SCAN 1 9 DIG 16 14 DIG 3 14 DIG 16 5 SCAN 1 1 SCAN...
result:
ok (100 test cases)
Test #10:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
100 16 16 17 23 13 17 1 1 16 16 25 37 11 17 0 1 1 16 16 45 33 23 25 0 1 1 16 16 44 20 28 20 0 1 1 16 16 33 41 19 29 1 1 16 16 29 21 19 17 1 1 16 16 47 37 23 27 1 1 16 16 18 24 16 12 0 1 1 16 16 36 38 20 34 1 1 16 16 21 33 11 17 0 1 1 16 16 31 29 27 19 0 1 1 16 16 28 52 4 28 1 1 16 16 17 29 17 11 1 1...
output:
SCAN 1 1 SCAN 1 16 SCAN 3 1 SCAN 1 7 DIG 4 13 DIG 3 1 SCAN 1 1 SCAN 1 16 SCAN 9 1 SCAN 1 5 DIG 10 6 DIG 8 6 DIG 10 5 SCAN 1 1 SCAN 1 16 SCAN 13 1 SCAN 1 11 DIG 14 12 DIG 12 12 DIG 14 11 SCAN 1 1 SCAN 1 16 SCAN 9 1 SCAN 1 14 DIG 10 16 DIG 9 16 DIG 10 13 SCAN 1 1 SCAN 1 16 SCAN 12 1 SCAN 1 6 DIG 16 10...
result:
ok (100 test cases)
Test #11:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
100 16 16 29 41 15 27 0 1 1 16 16 35 35 25 25 0 1 1 16 16 14 26 14 10 0 1 1 16 16 55 29 29 27 1 1 16 16 18 36 18 18 1 1 16 16 28 20 26 18 0 1 1 16 16 26 14 24 8 1 1 16 16 27 33 25 17 0 1 1 16 16 19 21 15 17 0 1 1 16 16 37 31 23 29 0 1 1 16 16 24 16 22 16 0 1 1 16 16 33 7 29 5 1 1 16 16 25 27 19 17 1...
output:
SCAN 1 1 SCAN 1 16 SCAN 11 1 SCAN 1 5 DIG 14 9 DIG 8 9 DIG 14 2 SCAN 1 1 SCAN 1 16 SCAN 11 1 SCAN 1 8 DIG 16 11 DIG 6 11 DIG 16 6 SCAN 1 1 SCAN 1 16 SCAN 3 1 SCAN 1 5 DIG 6 8 DIG 1 8 DIG 6 3 SCAN 1 1 SCAN 1 16 SCAN 14 1 SCAN 1 15 DIG 15 15 DIG 14 15 SCAN 1 1 SCAN 1 16 SCAN 7 1 SCAN 1 4 DIG 13 7 DIG ...
result:
ok (100 test cases)