QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#91553 | #4421. Taxi | WTR2007 | WA | 221ms | 12128kb | C++20 | 1.8kb | 2023-03-29 03:47:38 | 2023-03-29 03:47:40 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define MULT_TEST 1
using namespace std;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void Solve() {
int n, q;
n = read(); q = read();
vector<array<int, 3>> E;
vector<array<int, 4>> maxn(n + 2);
E.push_back({0, 0, 0});
for (int i = 1; i <= n; i++) {
int x = read(), y = read(), w = read();
E.push_back({w, x, y});
}
sort(E.begin(), E.end());
maxn[n + 1][0] = maxn[n + 1][1] = maxn[n + 1][2] = maxn[n + 1][3] = -INF;
for (int i = n; i >= 1; i--) {
maxn[i][0] = max(maxn[i + 1][0], - E[i][1] - E[i][2]);
maxn[i][1] = max(maxn[i + 1][1], E[i][1] - E[i][2]);
maxn[i][2] = max(maxn[i + 1][2], E[i][1] + E[i][2]);
maxn[i][3] = max(maxn[i + 1][3], - E[i][1] + E[i][2]);
}
while (q--) {
int tx = read(), ty = read();
int l = 1, r = n + 1, ans = 0;
auto Calc = [&](int x) {
int m1 = max(tx + ty + maxn[x][0], tx - ty + maxn[x][3]);
int m2 = max(- tx + ty + maxn[x][1], - tx - ty + maxn[x][2]);
return max(m1, m2);
};
while (l < r) {
int mid = (l + r) >> 1;
if (E[mid][0] < Calc(mid)) ans = max(ans, E[mid][0]), l = mid + 1;
else ans = max(ans, Calc(mid)), r = mid - 1;
}
printf("%lld\n", ans);
}
}
signed main() {
int T = 1;
#if MULT_TEST
T = read();
#endif
while (T--) Solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 221ms
memory: 12128kb
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:
983867956 983867956 999931280 889296369 996195073 950644260 999931280 996195073 993151028 999931280 997021372 997021372 997021372 996195073 994277211 999931280 994277211 997021372 996195073 996195073 986381060 996195073 993475197 996195073 999931280 996195073 999931280 994277211 997021372 999931280 ...
result:
wrong answer 4th lines differ - expected: '889687839', found: '889296369'