QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627542#9422. Two-star ContestE7k#WA 0ms3580kbC++202.7kb2024-10-10 16:16:002024-10-10 16:16:02

Judging History

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

  • [2024-10-10 16:16:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-10-10 16:16:00]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define gcd __gcd
using namespace std;
typedef pair<int,int> pii;
const int INF = 9e18;
const int inf = 2e9;
const int mod = 1e9 + 7;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t --)
    {
        int n ,m ,k;
        cin >> n >> m >> k ;
        vector<array<int,2>> a(n + 1);
        vector<vector<int>> p(n + 1,vector<int> (m + 1));
        for(int i = 1;i <= n;i ++)
        {
            cin >> a[i][0];
            a[i][1] = i;
            for(int j = 1;j <= m;j ++)
            {
                cin >> p[i][j];
            }
        }
        sort(a.begin()+1,a.end());
        int lst = 0,ma = 0;
        int i = 1;
        while(i <= n && a[i][1] == a[1][1])
        {
            int j = a[i][1];
            lst = 0;
            for(int k = 1;k <= m;k ++)
            {
                if(p[j][k] == -1)
                {
                    p[j][k] = 0;
                }
                else lst += p[j][k];
            }
            ma = max(ma,lst);
            i ++;
        }
        // cout << "HH";
        // continue;
        // ma = lst;
        bool ok = 1;
        for(;i <= n;i ++)
        {
            int j = a[i][1];
            int now = 0,cnt = 0;
            for(int k = 1;k <= m;k ++)
            {
                if(p[j][k] == -1)
                {
                    cnt ++;
                }
                else now += p[j][k];
            }
            int ans = 0;
            if(now > lst);
            else
            {
                int x = lst + 1 - now;
                if(cnt != 0)
                {
                    ans = x / cnt + 1;
                    cnt = x % cnt;
                }
                else ok = 0;
                if(cnt > 0 && ans > k) ok = 0;
                else if(cnt == 0 && ans - 1 > k) ok = 0;
            }
            ma = max(ma,max(now,lst + 1));
            for(int k = 1;k <= m;k ++)
            {
                if(p[j][k] == -1)
                {
                    if(cnt > 0) p[j][k] = ans,cnt --;
                    else p[i][k] = ans - 1;
                }
            }
            // ma = max(ma,)
            if(i + 1 <= n && a[i+1][1] > a[i][1]) lst = ma;
        }

        if(!ok) cout << "No\n";
        else
        {
            cout << "Yes\n";
            for(int i = 1;i <= n;i ++)
            {
                for(int j = 1;j <= m;j ++)
                {
                    cout << p[i][j] << ' ';
                }
                cout << endl;
            }
        }
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

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 4 -1 
0 2 2 5 
3 -1 -1 3 
No
Yes
1 2 3 
4 5 6 
No
Yes
1 -1 -1 
0 0 0 

result:

wrong answer Integer parameter [name=q_{i, j}] equals to -1, violates the range [0, 5] (test case 1)