QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627797#9422. Two-star ContestE7k#WA 20ms4404kbC++202.6kb2024-10-10 17:11:392024-10-10 17:11:39

Judging History

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

  • [2024-10-10 17:11:39]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:4404kb
  • [2024-10-10 17:11:39]
  • 提交

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][0] == a[1][0])
        {
            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 ++;
        }

        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[j][k] = ans - 1;
                }
            }

            if(i + 1 <= n && a[i+1][0] > a[i][0]) 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;
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

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

result:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 4404kb

input:

1013
3 2 1
1 -1 -1
2 0 1
3 -1 -1
4 8 96295
302790137 -1 849 -1 -1 33907 7926 9461 70117
695984050 -1 -1 56792 -1 -1 -1 19527 -1
302790137 12828 30553 40825 67577 91517 77952 55631 63781
302790137 29385 -1 -1 -1 750 -1 -1 -1
2 6 72716304
892657961 -1 -1 66436933 -1 45419040 55642613
892657961 -1 6271...

output:

Yes
0 0 
0 1 
1 1 
Yes
0 849 0 0 33907 7926 9461 70117 
0 0 56792 0 0 0 19527 0 
12828 30553 40825 67577 91517 77952 55631 63781 
29385 0 0 0 750 0 0 0 
Yes
0 0 66436933 0 45419040 55642613 
0 62712753 0 21765515 56544945 12385026 
Yes
569508118 569508118 569508118 569508117 569508117 569508117 5695...

result:

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