代码见下
#include<bits/stdc++.h>
#define int long long
#define PII pair< int, int >
using namespace std;
const int N = 1e5 + 5, mod = 998244353;
const double eps = 1e-8;
struct car{
int d, v, a;
double cl, cr;
} cars[N];
int T, n, m, L, V, p[N], fir_problem, sec_problem, cnt;
PII qj[N];
template< typename T >inline void read(T &x){bool f=1;x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=!f;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}x=(f?x:-x);return;}
template< typename T, typename ... L > void read(T &a , L && ... b) { read(a); read(b ...); }
int ksm(int a, int b, int p){int ans = 1;while(b){if(b & 1)ans =(ans*a)%p;b >>= 1;a = (a*a) % p;}return ans;}
void solve(){
read(n, m, L, V);
fir_problem = 0;
sec_problem = 0;
cnt = 0;
for (int i = 1; i <= n; i++) read(cars[i].d, cars[i].v, cars[i].a);
for (int i = 1; i <= m; i++) read(p[i]);
for (int i = 1; i <= n; i++){
if (cars[i].a == 0){
if (cars[i].v > V){
cars[i].cl = cars[i].d;
cars[i].cr = L;
}
else {
cars[i].cl = -1;
cars[i].cr = -1;
}
}
else {
double wy = double(V * V - cars[i].v * cars[i].v) / (2 * cars[i].a);
if (cars[i].d + wy > L){
cars[i].cl = -1;
cars[i].cr = -1;
}
else {
if (cars[i].a < 0){
cars[i].cl = cars[i].d;
cars[i].cr = cars[i].d + wy - eps;
}
else {
cars[i].cl = cars[i].d + wy + eps;
cars[i].cr = L;
}
}
}
}
for (int i = 1; i <= n; i++){
if (cars[i].cr < p[1] && cars[i].cl > p[m]) continue;
int l = 1, r = m;
while (l < r){
int mid = l + r >> 1;
if (p[mid] < cars[i].cl) l = mid + 1;
else r = mid;
}
if (p[l] <= cars[i].cr) fir_problem++;
else continue;
qj[++cnt].first = p[l];
l = 1, r = m;
while (l < r){
int mid = l + r + 1 >> 1;
if (p[mid] > cars[i].cr) r = mid - 1;
else l = mid;
}
qj[cnt].second = p[l];
}
// for (int i = 1; i <= n; i++) printf("%lf %lf\n", cars[i].cl, cars[i].cr);
for (int i = 1; i <= cnt; i++){
swap(qj[i].first, qj[i].second);
// printf("%lld %lld\n", qj[i].first, qj[i].second);
}
sort(qj + 1, qj + cnt + 1);
queue< int > q;
for (int i = 1; i <= cnt; i++){
swap(qj[i].first, qj[i].second);
// printf("%lld %lld\n", qj[i].first, qj[i].second);
if (q.empty() || q.front() < qj[i].first){
q.push(qj[i].second);
// printf("%lld\n", qj[i].second);
sec_problem++;
}
}
printf("%lld %lld\n", n, n - sec_problem);
}
signed main(){
// freopen("a.in", "r", stdin);
// freopen("a.out","w",stdout);
read(T);
while (T--) solve();
return 0;
}
小样例过了,大样例测不了,我的电脑会爆