60pts求调
查看原帖
60pts求调
1041765
AKkkk_TIX楼主2025/8/31 20:53
#include<bits/stdc++.h>
#define l first 
#define r second 
// #define DEBUG 1
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll M = 100005;

struct Car {
    ll d, v, a;
};

ll n, m, L, V;

void find_out_ans1(vector<Car> &car, vector<ll> &p, vector<pll> &tm)
{
    for(int i = 1; i <= n; i++)
    {

        if(car[i].a == 0)
        {
            if(car[i].v <= V) continue;
            
            auto x = lower_bound(p.begin(), p.end(), car[i].d);
            if(x != p.end())
            {
                tm.push_back(pll{*x, p[p.size() - 1]});
            }
            continue;
        }
        else if(car[i].a > 0)
        {
            if(car[i].v <= V)
            {
                double s = (V * V - car[i].v * car[i].v) / (2.0 * car[i].a) + car[i].d;
                if(s > L || s < car[i].d) continue;

                ll num = s + 1;
                auto x = lower_bound(p.begin(), p.end(), num);
                if(x != p.end())
                {
                    tm.push_back(pll{*x, p[p.size() - 1]});
                }
            }
            else
            {
                auto x = lower_bound(p.begin(), p.end(), car[i].d);
                if(x != p.end())
                {
                    tm.push_back(pll{*x, p[p.size() - 1]});
                }
            }
        }
        else
        {
            if(car[i].v <= V) continue;

            double s = (V * V - car[i].v * car[i].v) / (2.0 * car[i].a) + car[i].d;
            if(s <= car[i].d) continue;

            ll num = ceil(s - 1);

            auto x = lower_bound(p.begin(), p.end(), car[i].d);
            if(x == p.end()) continue;
            if(*x >= num) continue;

            if(s > L)
            {
                tm.push_back(pll{*x, p[p.size() - 1]});
            }
            else
            {
                tm.push_back(pll{*x, num});
            }
        }

    }

    cout << tm.size() - 1;
}

void find_out_ans2(vector<Car> &car, vector<ll> &p, vector<pll> &tm)
{
    if(tm.size() == 1) { cout << m; return; }
    sort(tm.begin(), tm.end(), [&](pll x, pll y) { return x.r < y.r; });
    ll last_end = tm[1].r, ans = 1;
    for(auto x : tm)
        if(x.l > last_end)
        {
            last_end = x.r; ans++;
        }
    cout << m - ans;
}

void solve()
{
    cin >> n >> m >> L >> V;
    vector<Car> car(n + 5);
    vector<ll> p;
    vector<pll> tm;

    tm.push_back(pll{-1, -1});
    for(int i = 1; i <= n; i++)
        cin >> car[i].d >> car[i].v >> car[i].a;
    
    for(int i = 1; i <= m; i++)
    {
        ll index; cin >> index;
        p.push_back(index);
    }

    find_out_ans1(car, p, tm); cout << " ";
    find_out_ans2(car, p, tm); cout << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll T;
    cin >> T;
    while(T--) solve();
    return 0;
}

记录详情

2025/8/31 20:53
加载中...