QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789680#9422. Two-star ContestyxdWA 35ms6400kbC++142.3kb2024-11-27 21:26:502024-11-27 21:26:56

Judging History

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

  • [2024-11-27 21:26:56]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:6400kb
  • [2024-11-27 21:26:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k;
bool com(vector<int>a,vector<int>b){
    if(a[0]!=b[0])return a[0]<b[0];
    else{
        int s1=0,s2=0,f1=0,f2=0;
        for(int i=1;i<=m;i++){
            if(a[i]!=-1)s1+=a[i];
            else f1++;
        }
        for(int i=1;i<=m;i++){
            if(a[i]!=-1)s2+=a[i];
            else f2++;
        }
        if(s1!=s2)
            return s1>s2;
        return f1>f2;
    }
}
void solve(){
    cin>>n>>m>>k;
    int a[n+1][m+1];
    vector<int>c[n+1];
    vector<int>r[n+1];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=m;j++){
            int x;cin>>x;
            c[i].push_back(x);
            a[i][j]=x;
        }
        c[i].push_back(i);
    }
    sort(c+1,c+1+n,com);
    c[0].push_back(c[1][0]);
    int ps=0,s=0,f=1;
    for(int i=1;i<=n;i++){
        int cnt=0;
        for(int j=1;j<=m;j++){
            if(c[i][j]!=-1)
                s+=c[i][j];
            else
                cnt++;
        }
        if(s>=ps){
            for(int j=1;j<=cnt;j++)
                r[c[i].back()].push_back(0);
            if(c[i][0]!=c[i-1][0]&&s==ps){
                if(cnt==0)f=0;
                else r[c[i].back()][0]++;
            }
        }else{
            int ca=ps-s;
            if(c[i][0]!=c[i-1][0])ca++;
            for(int j=1;j<=cnt;j++){
                if(ca>k){
                    r[c[i].back()].push_back(k);
                    ca-=k;
                }else{
                    r[c[i].back()].push_back(ca);
                    ca=0;
                }
            }
            if(ca>0)f=0;
        }
        int p=0;
        ps=0,s=0;
        for(int j=1;j<=m;j++){
            if(c[i][j]==-1)ps+=r[c[i].back()][p++];
            else ps+=c[i][j];
        }
    }
    if(f){
        cout<<"Yes\n";
        for(int i=1;i<=n;i++){
            int p=0;
            for(int j=1;j<=m;j++){
                if(a[i][j]==-1)cout<<r[i][p++]<<" ";
                else cout<<a[i][j]<<" ";
            }
            cout<<'\n';
        }
    }else{
        cout<<"No\n";
    }
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
        solve();
}

详细

Test #1:

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

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: 35ms
memory: 6400kb

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 96295 96295 96295 750 96295 25349 0 
Yes
0 0 66436933 0 45419040 55642613 
14090347 62712753 0 21765515 56544945 12385026 
Yes
975402536 975402536 9...

result:

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