QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#49713#4421. TaxilqhsmashRE 0ms0kbC++201.5kb2022-09-22 16:53:002022-09-22 16:53:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-22 16:53:03]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-09-22 16:53:00]
  • 提交

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...

output:


result: