Wa on #6求调
查看原帖
Wa on #6求调
552298
Greenzhe楼主2024/11/5 20:27
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N=1e5+5, M=1e6+5;

int n,m,len,tot;
int pos[M];
ll maxV;

struct vehicle{
    ll d,v,a;
}raw[M];

struct seg{
    int L,R;
}car[M];

bool cmp(seg x,seg y){
    return x.R<y.R;
}

// v0 -> v1 s=(v1^2-v0^2)/2a

void solve(){
    scanf("%d%d%d%lld",&n,&m,&len,&maxV);
    tot=0;
    for(int i=1;i<=n;++i)
        scanf("%lld%lld%lld",&raw[i].d,&raw[i].v,&raw[i].a);
    for(int i=1;i<=m;++i) scanf("%d",&pos[i]);
    sort(pos+1,pos+m+1);
    for(int i=1;i<=n;++i){
        ll d,v,a;
        d=raw[i].d, v=raw[i].v, a=raw[i].a;
        bool over=false;
        int L,R;
        if(a==0){
            if(v>maxV){
                over=true;
                L=d, R=len;
            }
        }
        else if(a<0){
            if(v>maxV){
                over=true;
                ll p=maxV*maxV-v*v, q=2*a;
                ll dist=p/q;
                if(p%q==0) dist--;

                L=d, R=min((ll)len,d+dist);
            }
        }
        else{
            if(v>maxV){
                over=true;
                L=d, R=len;
            }
            else{
                ll p=maxV*maxV-v*v, q=2*a;
                ll dist=p/q;
                if(p%q==0) dist++;
                if(d+dist<=len){
                    over=true;
                    L=d+dist, R=len;
                }
            }
        }
        if(over){
            //cout<<L<<' '<<R<<endl;
            int ct=lower_bound(pos+1,pos+m+1,L)-pos;
            if(ct<=m&&pos[ct]<=R){
                //cout<<i<<endl;
                car[++tot].L=L;
                car[tot].R=R;
            }
        }
    }
    printf("%d ",tot);

    int selected=0,maxr=0;
    sort(car+1,car+tot+1,cmp);
    for(int i=1;i<=tot;++i){
        if(maxr<car[i].L){
            int x=upper_bound(pos+1,pos+m+1,car[i].R)-pos-1;
            maxr=pos[x];
            selected++;
        }
    }
    printf("%d\n",m-selected);
}

int main(){
    int T;
    scanf("%d",&T);
    while(T--) solve();
    return 0;
}

目前90pts。貌似物理算错了?

有个**考场会这个题,挂成70。请问它配不配退役。

2024/11/5 20:27
加载中...