NightTide @ 2024-11-05 14:29:07
#include<bits/stdc++.h>
#define MAXN 100010
using namespace std;
struct sec{ double l, r; };
bool operator < (sec a, sec b){ return a.l < b.l; }
bool operator > (sec a, sec b){ return a.l > b.l; }
int t, n, m, len, lim, ans1, ans2;
int d[MAXN], v[MAXN], a[MAXN];
double p[MAXN];
bool check(double l, double r){
int p1 = lower_bound(p + 1, p + m + 1, l) - p;
int p2 = upper_bound(p + 1, p + m + 1, r) - p - 1;
if(p1 > m || p2 < 1) return false;
if(p1 > p2) return false;
return true;
}
int main(){
scanf("%d",&t);
while(t--){
ans1 = 0; ans2 = 0;
vector<sec> s;
scanf("%d%d%d%d",&n,&m,&len,&lim);
for(int i = 1; i <= n; i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
for(int i = 1; i <= m; i++) scanf("%lf",&p[i]);
sort(p + 1, p + m + 1);
for(int i = 1; i <= n; i++){
if(a[i] > 0){
int mv = v[i] * v[i] + 2 * a[i] * (len - d[i]);
if(mv <= lim * lim) continue;
else{
double dis = (lim * lim - v[i] * v[i]) / (a[i] * 2.0);
double l = d[i] + dis, r = lim;
if(check(l, r)){
s.push_back((sec){l, r});
ans1++;
}
}
}else if(a[i] < 0){
if(v[i] <= lim) continue;
else{
double dis = (lim * lim - v[i] * v[i]) / (a[i] * 2.0);
double l = d[i], r = d[i] + dis;
if(check(l, r)){
s.push_back((sec){l, r});
ans1++;
}
}
}else if(a[i] == 0 && v[i] > lim){
s.push_back((sec){0, (double)len});
ans1++;
}
}
sort(s.begin(), s.end());
for(int i = 0; i < s.size(); ){
double nl = s[i].l, nr = s[i].r;
i++;
while(s[i].l < nr && check(max(nl, s[i].l), min(nr, s[i].r))){
nl = max(nl, s[i].l);
nr = min(nr, s[i].r);
i++;
}
ans2++;
}
printf("%d %d\n",ans1, m - ans2);
}
return 0;
}
/*
3
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
WA 10 pts。求助,嘎嘎挂分。
我的思路是对于每辆车处理出超速区间,然后区间按左端点排序,处理区间交。
by lin_er @ 2024-11-05 16:30:25
@NightTide
by Crane_NF @ 2024-11-05 17:01:43
555我跟你思路一样,然后同学说也是精度问题,100pts->20pts QAQ