QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749279#9422. Two-star ContestYuu#WA 19ms4228kbC++233.3kb2024-11-14 23:20:032024-11-14 23:20:04

Judging History

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

  • [2024-11-14 23:20:04]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:4228kb
  • [2024-11-14 23:20:03]
  • 提交

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 V(n + 1, std::vector<int>(m + 1));
    std::vector info(n + 1, std::array<int, 4>{0, 0, 0, 0});

    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] += 1;
            }else{
                info[i][1] += V[i][j];
            }
        }
    }

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

    for(int i = 1;i <= n;i++){
        int j = i, cV = -1, Mn = 0;
        while(j <= n && info[j][0] == info[i][0]){
            Mn = std::max(Mn, info[j][1]);
            if(info[i][2] == 0){
                if(cV == -1){
                    cV = info[i][1];
                    if(cV <= vi[i - 1] || cV < Mn) {
                        std::cout<<"No\n";
                        return ;
                    }
                }else{
                    if(cV != info[i][1]){
                        std::cout<<"No\n";
                        return ;
                    }
                }
            }
            j++;
        }

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

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: 19ms
memory: 4228kb

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)