求救,WA#5 6 8 10

学术版

aleavf @ 2024-11-29 18:48:26

传送门

#include<bits/stdc++.h>
using namespace std;
const int N=100000;
struct node{
    int d,v,a,q;
}s[N];
struct zuoyou{
    int le,ri;
}c[N];
int t;
bool cmp(zuoyou aa,zuoyou bb){
    return aa.ri<bb.ri;
}
int p[N];
int main() {
    scanf("%d",&t);
    while(t--){
        memset(p,0,sizeof p);
        memset(c,0,sizeof c);
        memset(s,0,sizeof s);
        int n,m,V,l,ans=0,ans1=0,you=0;
        scanf("%d%d%d%d",&n,&m,&l,&V);
        for(int i = 1;i<=n;++i)
            scanf("%d%d%d",&s[i].d,&s[i].v,&s[i].a);
        for(int i = 1;i<=m;++i) scanf("%d",&p[i]);
        for(int i = 1;i<=n;++i){
            double y=(1.0*V*V-1.0*s[i].v*s[i].v)/(1.0*2*s[i].a)+s[i].d;
            int u=int(y);
            if(u!=y) ++u; 
            int L=1,R=m,mid;
            if(s[i].a==0){
                if(s[i].v<=V) continue;
                if(s[i].d>p[m]) continue;
                int mid=lower_bound(p+1,p+1+m,s[i].d) - p;
                ++ans;
                c[ans].le=mid,c[ans].ri=m;

            }
            if(s[i].a>0){
                if(s[i].d>p[m]) continue;
                if(u>p[m]) continue;
                int mid=lower_bound(p+1,p+1+m,u)-p;
                ans++;
                c[ans].le=mid,c[ans].ri=m;

            }
            if(s[i].a<0){
                if(y<=s[i].d) continue;
                if(s[i].v<=V) continue;
                int mid=lower_bound(p+1,p+1+m,s[i].d) - p;
                if(p[mid]<y)++ans;
                else continue;
                int w=mid;
                mid=lower_bound(p+1,p+1+m,y) - p;
                if(p[mid]!=y) --mid;
                c[ans].le=w,c[ans].ri=mid;
            }
        }
        sort(c+1,c+1+ans,cmp);
        for(int j = 1;j<=ans;++j){
            if(you<c[j].le){
                ans1++;
                you=c[j].ri;
            }
        }
        cout<<ans<<' '<<m-ans1<<endl;
    }
}

|