QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#749426#9422. Two-star Contestshenchuan_fanWA 27ms4176kbC++231.9kb2024-11-15 00:40:322024-11-15 00:40:32

Judging History

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

  • [2024-11-15 00:40:32]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:4176kb
  • [2024-11-15 00:40:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

//  The 2024 ICPC Kunming Invitational Contest

void sol(){
    int n, m, k;
    std::cin>>n>>m>>k;

    std::vector info(n + 1, std::array<int, 4>{0, 0, 0, 0});
    std::vector V(n + 1, std::vector<int>(m + 1));

    for(int i = 1;i <= n;i++){
        std::cin>>info[i][0];
        info[i][3] = i;
        for(int j = 1;j <= m;j++){
            std::cin>>V[i][j];
            if(V[i][j] == -1){
                info[i][2]++;
            }else{
                info[i][1] += V[i][j];
            }
        }
    }

    std::sort(info.begin() + 1, info.end());
    std::vector<int>vi(n + 1, -1);

    for(int i = 1;i <= n;i++){
        int j = i, Mn = 0;
        while(j <= n && info[i][0] == info[j][0]){
            Mn = std::max(Mn, info[j][1]);
            j++;
        }

        Mn = std::max(Mn, vi[i - 1] + 1);
        for(int u = i;u < j;u++){
            vi[u] = Mn;
            int ii = info[u][3];
            if(info[u][1] + info[u][2] * k < Mn){
                std::cout<<"No\n";
                return ;
            }
            //  cur <= Mn
            int cur = info[u][1];
            for(int v = 1;v <= m;v++){
                if(V[ii][v] == -1){
                    if(cur +k <= Mn){
                        V[ii][v] = k;
                        cur = cur + k;
                    }else{
                        V[ii][v] = Mn - cur;
                        cur = Mn;
                    }
                }
            }
        }
        i = j - 1;
    }

    std::cout<<"Yes\n";
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            std::cout<<V[i][j]<<" \n"[j == m];
        }
    }
}

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1; std::cin>>t;
    while(t--) sol();  
    return 0;
}

详细

Test #1:

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

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 5 3
0 5 0 5
3 4 0 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: 27ms
memory: 4176kb

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
No
Yes
0 0 66436933 0 45419040 55642613
14090347 62712753 0 21765515 56544945 12385026
Yes
975402536 975402536 975402536 975402536 975402536 248560376 0 0 0
975402536 975402536 263947305 0 211610436 944794448 0 0 0
788675016 424172233 162632689 465907153 203583296 975402536 372435832...

result:

wrong answer Participant fails to find an answer while the jury found one. (test case 2)