求小样例 Hack / 求调
查看原帖
求小样例 Hack / 求调
817365
qfy123楼主2024/10/27 11:09

RT。

最后一个大样例过不去。是在求最小关闭多少检测点的部分出了问题,但死活调不出来。

#include<bits/stdc++.h>
#define int long long 
#define ull unsigned long long
#define ri register int
#define rep(i,j,k) for(ri i=(j);i<=(k);++i) 
#define per(i,j,k) for(ri i=(j);i>=(k);--i)
#define repl(i,j,k,l) for(ri i=(j);(k);i=(l))
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pc(x) putchar(x)
#define fir first
#define se second 
#define MP pair<int,int>
#define pii pair<int,int>
#define PB push_back
#define lson p << 1
#define rson p << 1 | 1
using namespace std;
char BUFFER[100000],*P1(0),*P2(0);
#define gtc() (P1 == P2 && (P2 = (P1 = BUFFER) + fread(BUFFER,1,100000,stdin), P1 == P2) ? EOF : *P1++)
inline int R(){
    int x;char c;bool f = 0;
	while((c = gtc()) < '0') if(c == '-') f = 1;
	x = c ^ '0';
	while((c = gtc()) >= '0') x = (x << 3) + (x << 1) + (c ^ '0');
	return f?(~x + 1):x;
}
inline void O(int x){
    if(x < 0) pc('-'),x = -x;
    if(x < 10) pc(x + '0');
    else O(x / 10),pc(x % 10 + '0');
}
inline void out(int x,int type){
	if(type == 1) O(x),pc(' ');
	if(type == 2) O(x),pc('\n');
	if(type == 3) O(x);
}
inline void OI(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
const int N = 1e5 + 10;
const double eps = 1e-9;
struct C{
	int d, v, a;
}c[N];
struct S{
	int l, r;
}s[N];
int n, m, L, V, p[N], cnt;
bool cmp(S x, S y){
	return x.r < y.r;
}
inline void solve(){
	cnt = 0;
	n = R(), m = R(), L = R(), V = R();
	rep(i, 1, n) c[i] = {R(), R(), R()};
	rep(i, 1, m) p[i] = R();
	rep(i, 1, n){
		if(c[i].a == 0){
			if(c[i].d <= p[m] && c[i].v > V){
				int pos = lower_bound(p + 1, p + m + 1, c[i].d) - p;
				s[++cnt] = {pos, m};
			}
		}else if(c[i].a > 0){
			if(c[i].v > V){
				int p1 = lower_bound(p + 1, p + m + 1, c[i].d) - p;
				if(p1 > m) continue;
				s[++cnt] = {p1, m};
				continue;
			}
			double dis = (V * V - c[i].v * c[i].v * 1.0) / (2.0 * c[i].a) * 1.0 + c[i].d;
			int p1 = lower_bound(p + 1, p + m + 1, dis) - p;
			if(fabs(dis - p[p1]) < eps) p1++;
			if(p1 > m) continue;
			s[++cnt] = {p1, m};
		}else if(c[i].a < 0){
			if(c[i].v <= V) continue;
			double dis = (V * V - c[i].v * c[i].v) / (2 * c[i].a) * 1.0 + c[i].d;
			int p1 = lower_bound(p + 1, p + m + 1, c[i].d) - p;
			int p2 = lower_bound(p + 1, p + m + 1, dis) - p;
			if(fabs(dis - p[p2] * 1.0) > eps) p2--; 
			if(p1 > p2) continue;
			s[++cnt] = {p1, p2};
		}
	}
	out(cnt, 1);
	int nr = -1, s2 = 0;
	sort(s + 1, s + cnt + 1, cmp);
	rep(i, 1, cnt){
		if(s[i].l > nr){
			++s2;
			nr = s[i].r;
		}
	}
	out(m - s2, 2);
}
signed main(){
    // OI();
    int T = 1;
    T = R();
//     
    // IOS;int T = 1;
    // cin >> T;
	while(T--) solve();
	return 0;
}
2024/10/27 11:09
加载中...