QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49713 | #4421. Taxi | lqhsmash | RE | 0ms | 0kb | C++20 | 1.5kb | 2022-09-22 16:53:00 | 2022-09-22 16:53:03 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 19;
const int MOD = 998244353;
int T, n, q, e[4][N];
struct node {
int x, y, w;
}a[N];
bool operator < (node l, node r) {
return l.w < r.w;
}
int main () {
freopen ("in.in", "r", stdin);
freopen ("out.out", "w", stdout);
scanf ("%d", &T);
while (T --) {
scanf ("%d%d", &n, &q);
for (int i = 1; i <= n; i ++) {
scanf ("%d%d%d", &a[i].x, &a[i].y, &a[i].w);
}
sort (a + 1, a + 1 + n);
for (int i = 0; i < 4; i ++) e[i][n + 1] = -2e9;
for (int i = n; i >= 1; i --) {
e[0][i] = max (e[0][i + 1], a[i].x + a[i].y);
e[1][i] = max (e[1][i + 1], -a[i].x + a[i].y);
e[2][i] = max (e[2][i + 1], -a[i].x - a[i].y);
e[3][i] = max (e[3][i + 1], a[i].x - a[i].y);
}
for (int i = 1; i <= q; i ++) {
int x, y; scanf ("%d%d", &x, &y);
int l = 1, r = n, ans = 0;
while (l <= r) {
int mid = (l + r) >> 1;
int chk = max ({e[0][mid]-x-y, e[1][mid]+x-y, e[2][mid]+x+y, e[3][mid]-x+y});
if (chk >= a[mid].w) {
ans = max (ans, a[mid].w);
l = mid + 1;
}else {
ans = max (ans, chk);
r = mid - 1;
}
}
printf("%d\n", ans);
}
}
return 0;
}
详细
Test #1:
score: 0
Dangerous Syscalls
input:
75 1000 1000 205432745 470548752 641881064 972832623 639054913 762973519 678871215 803867430 118261958 833419731 349421812 375017045 561177932 673829619 184524659 764937037 83708877 781504446 347223352 714500823 323457000 398512793 494262891 64649652 138888103 741302375 289501778 306141751 893073089...