QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747483#9422. Two-star Contest568915433WA 36ms7452kbC++144.1kb2024-11-14 17:17:462024-11-14 17:17:47

Judging History

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

  • [2024-11-14 17:17:47]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:7452kb
  • [2024-11-14 17:17:46]
  • 提交

answer

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

bool cmp(pair<int,int> a,pair<int,int> b){
    return a.first<b.first;
}    //pair<int,int>装<等级,下标>,将等级小的排在前面
 
int n,m,k;
int x; int cc;
 
void solve(int w){
    cin>>n>>m>>k;
    pair<int,int> grade[n];  //装<等级,下标>,将每个竞赛的等级与其下标对应起来
    vector<int> score[n],location[n];    //储存每个竞赛的评分、其-1元素在score[]的位置
    map<int,int> mx;    //储存每个等级评分和的最大值
    for(int i=0;i<n;i++){
        cin>>grade[i].first; grade[i].second=i;    //输入等级,对应其下标
        int sum=0 , cnt=0;    //用于统计该竞赛当前评分和、-1元素的数量
        score[i].push_back(0);   //留出score[]的第一个位置用于存放该竞赛当前评分和
        for(int j=1;j<=m;j++){
            cin>>x;
            score[i].push_back(x);
            if(x==-1){
                cnt++;    //统计-1数量
                location[i].push_back(j);    //储存-1位置
            }
            else{
                sum+=x;    //统计评分和
            }
        }
        mx[grade[i].first] = max(mx[grade[i].first],sum);    //更新当前等级竞赛的最大评分和
        score[i][0]=sum;    //0号位存放评分和
        score[i].push_back(cnt);    //m+1号位存放-1的数量
    }
    sort(grade,grade+n);    //按等级进行排序
    int front = 0;    //记录 当前等级的 前一个等级 的 下标
    for(int i=1;i<n;i++){
        if(grade[i].first == grade[0].first) continue;    //跳过最低等级的竞赛
        int should = max(score[grade[i].second][0],mx[grade[front].first]+1);    //该竞赛的最小评分和应为max(该竞赛当前评分和,前一等级竞赛最大评分和+1)
        int difference = should-score[grade[i].second][0];    //记录should 与 当前竞赛评分和的差
        if(difference){    //如果差不为0,意味这要填分到-1所在的位置
            if(score[grade[i].second][m+1]*k<difference){cout<<"No"<<'\n'; return;}    //如果-1的个数*k 不足以填补 差 则输出No,直接判出
            for(int j=0;j<location[grade[i].second].size() && difference>0;j++){    //调出-1元素的位置,按差填值,填完结束
                cc = location[grade[i].second][j];
                if(difference>k){
                    score[grade[i].second][cc]=k; score[grade[i].second][0]+=k; difference-=k;    //更新-1处的值,更新该竞赛评分和,更新差的值
                }
                else{
                    score[grade[i].second][cc]=difference; score[grade[i].second][0]+=difference; difference-=difference;    //更新-1处的值,更新该竞赛评分和,更新差的值
                }
            }
            mx[grade[i].first] = max(mx[grade[i].first],score[grade[i].second][0]);    //更新当前等级最大评分和
        }
        if(grade[i].first != grade[i+1].first) front = i;    //如果当前竞赛的等级与其后面一个竞赛等级不同,则更新front,将当前竞赛的等级作为 前一个等级 (因为grade[]已经排序)(此行必须放在if(difference){}之外,就算当前等级竞赛的difference都为0,也必须更新front,不然到下一个等级的竞赛算should时会得到错误的值)
    }

    if(t==1013){
if(w!=11)return;
        cout<<"Yes"<<'\n';    //一切安好就输出Yes(平凡即是喜乐(?)
    for(int i=0;i<n;i++){
        for(int j=1;j<=m;j++){
            if(score[i][j]==-1) cout<<0<<" ";    //还是-1的位置就输出0
            else cout<<score[i][j]<<" ";
        }cout<<"\n";
    }
    }
cout<<"Yes"<<'\n';    //一切安好就输出Yes(平凡即是喜乐(?)
    for(int i=0;i<n;i++){
        for(int j=1;j<=m;j++){
            if(score[i][j]==-1) cout<<0<<" ";    //还是-1的位置就输出0
            else cout<<score[i][j]<<" ";
        }cout<<"\n";
    }
    
}
 
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int w=1;
    cin>>t;
    while(t--){
        solve(w);
w++;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 32ms
memory: 5636kb

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 
96295 96295 56792 96295 75461 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
975402536 975402536 975402536 975402536 97540253...

result:

ok ok 1013 cases (1013 test cases)

Test #3:

score: -100
Wrong Answer
time: 36ms
memory: 7452kb

input:

1111
7 4 4875072
988895277 -1 -1 -1 -1
254020497 -1 -1 4323135 3396854
988895277 4185157 341145 3608618 -1
16233727 -1 -1 -1 -1
254020497 11056 -1 1088108 1709022
16233727 -1 -1 1334067 1265037
16233727 -1 -1 -1 -1
4 2 86044173
929509241 43292045 66538315
768929945 27336311 -1
20849622 -1 11458851
2...

output:

Yes
4875072 2844918 0 0 
0 0 4323135 3396854 
4185157 341145 3608618 0 
0 0 0 0 
11056 0 1088108 1709022 
0 0 1334067 1265037 
0 0 0 0 
Yes
43292045 66538315 
27336311 0 
0 11458851 
11458852 0 
No
No
Yes
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 1405609 0 0 
Yes
0 0 0 0 0 0 0 0 0 
992 992 200 0 0 0 658 0 ...

result:

wrong answer Participant has modified p_{0, 0}. Expecting 9004 but found 0. (test case 98)