社区讨论
80 pts 求调
P11232[CSP-S 2024] 超速检测参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m2syehih
- 此快照首次捕获于
- 2024/10/28 19:46 去年
- 此快照最后确认于
- 2025/11/04 15:47 4 个月前
CPP
#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<random>
#include<chrono>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
typedef pair<int,int>PII;
const int N=2e5+10,inf=1e9;
int T;
int n,m,L,V,tt,st[N];
int p[N],cnt,ans,last,mn;
struct car{
int d,v,a;
int l,r;
}c[N];
struct segment{
int l,r;
}seg[N];
bool cmp(segment a,segment b){
if(a.l==b.l)return a.r>b.r;
return a.l<b.l;
}
PII calc(double d,double v,double a){
if(a==0){
if(v>V)return {d,L};
return {-1,-1};
}
else if(a>0){
if(v>=V)return {d+(V==v),L};
else{
double s=1.0*((V*V)-(v*v))/2/a;
int S=d+int(s)+1;
if(S<=L)return {S,L};
else return {-1,-1};
}
}
else if(a<0){
if(v<=V)return {-1,-1};
else{
double s=1.0*((V*V)-(v*v))/2/a;
int S=d+int(s);
return {d,min(S,L)};
}
}
}
void init(){
for(int i=0;i<=n;i++)st[i]=0;
tt=cnt=ans=0;
last=-1,mn=1e9;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// freopen("detect5.in","r",stdin);
// freopen("detect5.out","w",stdout);
cin>>T;
while(T--){
cin>>n>>m>>L>>V;
init();
for(int i=1;i<=n;i++){
int d,a,v;
cin>>d>>v>>a;
auto k=calc(d,v,a);
c[i]={d,v,a,k.first,k.second};
}
for(int i=1;i<=m;i++)cin>>p[i];
sort(p+1,p+1+m);
for(int i=1;i<=n;i++){
int l=c[i].l,r=c[i].r;
if(l==-1||r==-1||c[i].d>p[m])continue;
int ll=lower_bound(p+1,p+1+m,l)-p;
int rr=upper_bound(p+1,p+1+m,r)-p-1;
if(rr>=ll)cnt++,seg[++tt]={ll,rr};
}
sort(seg+1,seg+1+tt,cmp);
for(int i=tt;i;i--){
if(seg[i].r<mn){
st[i]=1;
mn=seg[i].r;
}
else st[i]=0;
}
for(int i=1;i<=tt;i++){
if(seg[i].l>last&&st[i])
ans++,last=seg[i].r;
}
cout<<cnt<<' '<<m-ans<<'\n';
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...