QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#41296 | #4421. Taxi | DaBenZhongXiaSongKuaiDi# | WA | 390ms | 9248kb | C++14 | 1.3kb | 2022-07-29 13:59:43 | 2022-07-29 13:59:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = (int)1e5+5;
int T,n,q; int val[4][maxn]; // min x+y x-y -x+y -x-y
struct Node{
int x,y,w;
bool operator < (const Node&T) const {return w > T.w;}
}a[maxn];
inline int getdis(int x,int y,int idx){
return max(x+y-val[0][idx],max(x-y-val[1][idx],max(-x+y-val[2][idx],-x-y-val[3][idx])));
}
signed main(){
scanf("%lld",&T);
while(T--){
scanf("%lld%lld",&n,&q);
for(int al=1;al<=n;al++) scanf("%lld%lld%lld",&a[al].x,&a[al].y,&a[al].w);
sort(a+1,a+n+1);
val[0][1] = a[1].x+a[1].y,
val[1][1] = a[1].x-a[1].y,
val[2][1] = -a[1].x+a[1].y,
val[3][1] = -a[1].x-a[1].y;
for(int al=2;al<=n;al++)
val[0][al] = min(val[0][al-1],a[al].x+a[al].y),
val[1][al] = min(val[1][al-1],a[al].x-a[al].y),
val[2][al] = min(val[2][al-1],-a[al].x+a[al].y),
val[3][al] = min(val[3][al-1],-a[al].x-a[al].y);
for(int al=1;al<=q;al++){
int A,B; scanf("%lld%lld",&A,&B);
if(getdis(A,B,n)<=a[n].w) {printf("%lld\n",getdis(A,B,n)); continue;}
if(getdis(A,B,1)>=a[1].w) {printf("%lld\n",a[1].w); continue;}
int l=1, r=n;
while(l+1<r){
int now = (l+r)>>1;
if(getdis(A,B,now)<=a[n].w) l=now;
else r=now;
}
printf("%lld\n",max(getdis(A,B,l),a[r].w));
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 390ms
memory: 9248kb
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:
998805741 998805741 999931280 998805741 998805741 998805741 999931280 998805741 998805741 999931280 998805741 998805741 998805741 998805741 998805741 999931280 998805741 998805741 998805741 998805741 998805741 998805741 998805741 998805741 999931280 998805741 999931280 998805741 998805741 999931280 ...
result:
wrong answer 1st lines differ - expected: '983867956', found: '998805741'