求调
查看原帖
求调
167697
BartAllen楼主2024/10/27 21:49

赛时代码被不明撤销键吞,调不回去,200变140,回来重新写了一遍挂了,实在想不出哪里呵赛时写的不一样,望周知

#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

int n, m, L, V, T, a[N], p[N];
bool vis[N];

struct Car {
	int d, v, a;
	double rx;	// reach V x
} c[N];

struct Available {
	int l, r;
} s[N];

bool cmp(Available s1, Available s2) {
	return s1.l < s2.l;
}

int solve() {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (c[i].d > p[m]) continue;
		int x0 = lower_bound(p + 1, p + m + 1, c[i].d) - p;
		if (c[i].a == 0 && c[i].v > V) {
			ans++;
			s[ans] = (Available) {x0, p[m]};
		}
		if (c[i].a > 0) {
			int x = upper_bound(p + 1, p + m + 1, c[i].rx) - p;
			if (x < m || x == m && p[m] > c[i].rx && c[i].d <= p[m]) {
				ans++;
				s[ans] = (Available) {min(x, x0), p[m]};
			}
		}
		if (c[i].a < 0) {
			int x = lower_bound(p + 1, p + m + 1, c[i].rx) - p;
			if (p[x] >= c[i].rx) x--;
			if (x > x0) {
				ans++;
				s[ans] = (Available) {x0, x};
			}
		}
	}
	return ans;
}

int main() {
	freopen("detect5.in", "r", stdin);
	freopen("Barsoka.out", "w", stdout); 
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> T;
	while (T--) {
		cin >> n >> m >> L >> V;
		for (int i = 1; i <= n; i++) {
			int x, y, z;
			cin >> x >> y >> z;
			c[i] = (Car) {x, y, z, 1.0 * (V * V - y * y) / (2.0 * z) + 1.0 * x};
		}
		for (int i = 1; i <= m; i++) cin >> p[i];
		int ans = solve();
		sort(s + 1, s + ans + 1, cmp);
		int minr = 0x3f3f3f3f;
		for (int i = ans; i; i--) {
			if (s[i].r < minr) minr = s[i].r, vis[i] = 1;
			else vis[i] = 0;
		}
		int cnt = 0, lst = -1;
		for (int i = 1; i <= ans; i++)
			if (vis[i] && s[i].l > lst) {	// not covered yet
				cnt++;
				lst = s[i].r;
			}
		cout << ans << " " << m - cnt << endl;
	}
	return 0;
}
2024/10/27 21:49
加载中...