才想起来补这题。
#include<bits/stdc++.h>
using namespace std;
namespace qwq{
int read(){
int n = 0;
int f = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
n = (n << 1) + (n << 3) + (c ^ 48);
c = getchar();
}
return n * f;
}
}
using namespace qwq;
struct car{
int d, v, a;
int l, r;
} a[1000010];
struct node{
int l, r;
bool operator < (const node &A){
if(r == A.r) return l < A.l;
return r < A.r;
}
} w[1000010];
int sum[1000010], n, m, l, V, p[1000010], cnt, T, b[1000010], ans;
int solve(int a, int v){
return (V*V - v*v) / (2*a) + 1;
}
int solve1(int a, int v){
if((V*V - v*v) % (2*a) == 0) return (V*V - v*v) / (2*a) - 1;
else return (V*V - v*v) / (2*a);
}
int main(){
//freopen("detect.in", "r", stdin);
//freopen("detect.out", "w", stdout);
T = read();
while(T--){
memset(p, 0, sizeof(p));
memset(sum, 0, sizeof(sum));
cnt = 0;
ans = 0;
memset(b, 0, sizeof(b));
n = read(), m = read(), l = read(), V = read();
for(int i = 1; i <= n; i++){
a[i].d = read(), a[i].v = read(), a[i].a = read();
if(a[i].a < 0){
if(a[i].v <= V) a[i].l = a[i].r = -1;
else if(a[i].v > V){
a[i].l = a[i].d;
a[i].r = min(solve1(a[i].a, a[i].v) + a[i].d, l);
}
}
if(a[i].a == 0){
if(a[i].v <= V) a[i].l = a[i].r = -1;
else a[i].l = a[i].d, a[i].r = l;
}
if(a[i].a > 0){
if(solve(a[i].a, a[i].v) + a[i].d > l) a[i].l = a[i].r = -1;
else a[i].l = max(solve(a[i].a, a[i].v), 0) + a[i].d, a[i].r = l;
}
}
for(int i = 1; i <= m; i++){
int x;
x = read();
p[x] = 1;
b[i] = x;
}
sum[0] = p[0];
for(int i = 1; i <= l; i++){
sum[i] = sum[i-1] + p[i];
}
for(int i = 1; i <= n; i++){
if(a[i].r < 0) continue;
if(sum[a[i].r] - (a[i].l == 0 ? 0 : sum[a[i].l-1])){
cnt++;
w[cnt].l = a[i].l;
w[cnt].r = a[i].r;
}
}
printf("%d ", cnt);
sort(w+1, w+cnt+1);
sort(b+1, b+m+1);
int id = 1;
while(b[id] <= w[1].r && id <= m) id++;
id--;
ans = 1;
for(int i = 2; i <= cnt; i++){
if(b[id] >= w[i].l && b[id] <= w[i].r && ans > 0) continue;
while(b[id] <= w[i].r && id <= m) id++;
id--;
ans++;
}
printf("%d\n", m - ans);
}
return 0;
}