跪求求佬hack一下
查看原帖
跪求求佬hack一下
552078
Saint_ZF楼主2023/9/4 15:42

测试了很多样例都找不到问题,提交的时候Subtask1全WA,Subtask5里面的37、39、40、41、42、43是WA,得分25,求佬hack一下

#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

typedef long long LL;

vector<LL> add;

bool check(LL n, LL d, LL k)
{
    add.clear();
    LL deep = 1;
    while (d > 0)
    {
        if (n < k) return false;
        d -= n;
        while (d < k && d)
        {
            if (deep == 1) return false;
            d++, n--;
            add.back()++;
        }
        n -= k;
        add.push_back(k);
        deep++;
    }
    add.back() += n;
    return true;
}

int main(void)
{
    int T;
    cin >> T;

    while (T--)
    {
        LL n, d, k;
        cin >> n >> d >> k;

        if (check(n-1, d, k))
        {
            cout << "YES" << endl;
            LL cnt = 1;
            for (auto item : add)
            {
                for (LL i = 0; i < item; i++) cout << cnt << ' ';
                cnt+=item;
            }
            cout << endl;
        }
        else cout << "NO" << endl;
    }

    return 0;
}
2023/9/4 15:42
加载中...