社区讨论
求个大佬看看
P11232[CSP-S 2024] 超速检测参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @m2vw1tq5
- 此快照首次捕获于
- 2024/10/30 21:04 去年
- 此快照最后确认于
- 2024/10/30 22:59 去年
CPP
#include<bits/stdc++.h>
#define MAXN 100010
//#define int long long
using namespace std;
typedef long long LL;
struct node{
int l;
int r;
}nb[MAXN];
int t;
int n,m,L,V,top,p[MAXN],d[MAXN],v[MAXN],a[MAXN];
int bey;
long double ss(int rr){
return (long double)(V*V-v[rr]*v[rr])*1.0/(2*a[rr])+d[rr];
}
bool cmp(node x,node y){
if(x.r!=y.r) return x.r<y.r;
return x.l<y.l;
}
bool fii(int mi,int ma){
int l=1,r=m;
while(l<r){
int mid=(l+r)>>1;
if(p[mid]>=mi&&p[mid]<=ma) return true;
if(p[mid]<mi){
l=mid+1;
}else if(p[mid]>ma){
r=mid;
}
}
return false;
}
int main(){
//freopen("detect4.in","r",stdin);
//freopen("detect.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--){
cin>>n>>m>>L>>V;
bey=0;top=0;
for(int i=1;i<=n;i++)
cin>>d[i]>>v[i]>>a[i];
for(int i=1;i<=m;i++)
cin>>p[i];
for(int i=1;i<=n;i++){
while(d[i]>p[m]) continue;
if(a[i]==0){
if(v[i]>V) {nb[++top].l=d[i];nb[top].r=p[m];}
}
if(a[i]>0){
if(v[i]>V) {nb[++top].l=d[i];nb[top].r=p[m];}
else {
if(v[i]==V) {nb[++top].l=d[i]+1;nb[top].r=p[m];}
else{
int pd=ss(i)+1;
if(pd==ss(i)+1) pd--;
if(pd<=p[m]) {nb[++top].l=pd;nb[top].r=p[m];}
}
}
}
if(a[i]<0){
if(v[i]>V){
int pd=ss(i);
if(pd==ss(i)) pd--;
// if(pd>p[m]) {pd=p[m]};
if(fii(d[i],pd)) {nb[++top].l=d[i];nb[top].r=pd;}
}
}
//cout<<i<<" "<<top<<endl;
}
sort(nb+1,nb+top+1,cmp);
int K=0;int kk=1;
for(int i=1;i<=top;i++){
if(nb[i].l<=K) continue;
else{
bey++;
while(p[kk+1]<=nb[i].r&&kk<m)
kk++;
K=p[kk];
}
}
cout<<top<<" "<<m-bey<<endl;
}
//fclose(stdin);
//fclose(stdout);
return 0;
}
虽然代码很长但是很好理解,好无语啊,总是有些莫名其妙的地方大一或者小一,我看不出来哪点有问题(自认为思路是对的)
回复
共 2 条回复,欢迎继续交流。
正在加载回复...