QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664476#9422. Two-star ContestYoriWA 29ms5128kbC++142.1kb2024-10-21 20:50:592024-10-21 20:51:00

Judging History

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

  • [2024-10-21 20:51:00]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:5128kb
  • [2024-10-21 20:50:59]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
#define mk make_pair
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 2e6+7;
int n, m, k, x;

struct node{
    int s=0,sum=0,max1=0,num1=0,p;
    vector<int>v;
};

int cmp1(node a,node b){
    return a.p<b.p;
}

int cmp2(node a,node b){
    return a.s==b.s?a.sum<b.sum:a.s>b.s;
}

void sovle()
{
    cin>>n>>m>>k;
    node a[n+5];
    map<int,int>maxs,minm,u;
    for(int i=1;i<=n;i++){
        cin>>a[i].s;
        for(int j=1;j<=m;j++){
            cin>>x;
            if(x==-1) a[i].num1++;
            else{
                a[i].sum+=x;
            }
            a[i].v.push_back(x);
        }
        a[i].max1=a[i].sum+a[i].num1*k;
        a[i].p=i;
        if(maxs.count(a[i].s)) maxs[a[i].s]=max(maxs[a[i].s],a[i].sum);
        else maxs[a[i].s]=a[i].sum;
        if(minm.count(a[i].s)) minm[a[i].s]=min(minm[a[i].s],a[i].max1);
        else minm[a[i].s]=a[i].max1;
    }
    sort(a+1,a+n+1,cmp2);
    u[a[1].s]=minm[a[1].s];
    for(int i=1;i<=n;i++){
        if(maxs[a[i].s]>minm[a[i].s]){
            cout<<"No"<<endl;
            return;
        }
        if(i>=2&&a[i].s!=a[i-1].s){
            if(maxs[a[i].s]>=u[a[i-1].s]){
                cout<<"No"<<endl;
                return;
            }
            u[a[i].s]=min(minm[a[i].s],u[a[i-1].s]-1);
        }
    }
    sort(a+1,a+n+1,cmp1);
    for(int i=1;i<=n;i++){
        int ko=u[a[i].s]-a[i].sum;
        for(int j=0;j<m;j++){
            if(a[i].v[j]!=-1) continue;
            if(ko){
                a[i].v[j]=min(k,ko);
                ko=max(0ll,ko-k);
            }else a[i].v[j]=0;
        }
        if(ko){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=0;j<m;j++){
            cout<<a[i].v[j]<<' ';
        }cout<<endl;
    }
}

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

    return 0;
}

详细

Test #1:

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

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

result:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 5128kb

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
72716304 58625957 66436933 0 45419040 55642613 
72716304 62712753 72716304 21765515 56544945 12385026 
Yes
975402536 975402536 975402536 975402536 975402536 372427170 0 0 0 
975402536 975402536 975402536 975402536 211610436 944794448 67558026 0 0 
788675016 424172233 162632...

result:

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