QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676461#9422. Two-star ContestLianYanWA 4ms25460kbC++201.8kb2024-10-25 21:38:342024-10-25 21:38:35

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 21:38:35]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:25460kb
  • [2024-10-25 21:38:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 4e5 + 10;
struct node
{
    int lev;
    int sum;
    int num;
    vector<int> vct;
    int ind;
} a[N];
bool cmp1(node a, node b)
{
    if (a.lev == b.lev)
        return a.sum < b.sum;
    return a.lev < b.lev;
}
bool cmp2(node a, node b)
{
    return a.ind < b.ind;
}
void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
    {
        a[i].vct.clear();
        a[i].num = 0;
        a[i].sum = 0;
        cin >> a[i].lev;
        a[i].ind = i;
        int t = 0;
        for (int j = 1; j <= m; j++)
        {
            cin >> t;
            a[i].sum += t;
            if (t == -1)
                a[i].num++;
            a[i].vct.push_back(t);
        }
        a[i].sum += a[i].num;
    }
    sort(a + 1, a + 1 + n, cmp1);
    a[0].lev = a[1].lev;
    int last = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i].lev != a[i - 1].lev)
        {
            last++;
        }
        if (a[i].sum < last)
        {
            int temp = last - a[i].sum;
            for (auto it : a[i].vct)
            {
                if (it == -1)
                {
                    it = min(k, temp);
                    temp -= it;
                }
            }
            if (temp)
            {
                cout << "No" << endl;
                return;
            }
        }
        else
        {
            last = max(a[i].sum, last);
        }
    }
    sort(a + 1, a + 1 + n, cmp2);
    cout << "Yes" << endl;
    for (int i = 1; i <= n; i++)
    {
        for (auto it : a[i].vct)
            cout << (it == -1 ? 0 : it) << " ";
        cout << endl;
    }
}

signed main()
{
    int T = 1;
    cin >> T;
    while (T--)
    {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 25460kb

input:

5
3 4 5
5 1 3 -1 -1
2 -1 5 -1 5
3 3 -1 -1 4
2 3 10
10000 5 0 -1
1 10 10 10
2 3 10
10 1 2 3
100 4 5 6
2 3 10
100 1 2 3
10 4 5 6
2 3 10000
100 -1 -1 -1
1 -1 -1 -1

output:

Yes
1 3 0 0 
0 5 0 5 
3 0 0 4 
No
Yes
1 2 3 
4 5 6 
No
Yes
0 0 0 
0 0 0 

result:

wrong answer Participant cannot satisfy the constraint. (test case 1)