QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643354#9422. Two-star Contestdqw#WA 64ms4240kbC++232.3kb2024-10-15 20:49:372024-10-15 20:49:38

Judging History

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

  • [2024-10-15 20:49:38]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:4240kb
  • [2024-10-15 20:49:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n,m,k;cin>>n>>m>>k;
    vector<pair<pair<int,int>,pair<int,int>>>info(n);
    vector<vector<int>>a(n,vector<int>(m));
    for(int i=0;i<n;i++)
    {
        int s;cin>>s;
        info[i].first.first=s;
        int sum=0,cnt=0;
        for(int j=0;j<m;j++)
        {
            int f;cin>>f;
            a[i][j]=f;
            if(f==-1)cnt++;
            else sum+=f;
        }
        int mx=sum+cnt*k,mn=sum;
        info[i].second={mn,mx};
        info[i].first.second=i;
    }
    sort(info.rbegin(),info.rend());
    vector<int>g(n);
    int cur=info[0].second.second;
    g[0]=cur;
    for(int i=1;i<n;i++)
    {
        if(info[i].first.first==info[i-1].first.first)
        {
            int L=i-1;
            int R=i;
            while(i+1<n and info[i].first.first==info[i+1].first.first)
            {
                R++;
                i++;
            }
            int hi=1e18,lo=0;
            for(int j=L;j<=R;j++)
            {
                auto [mn,mx]=info[j].second;
                if(mx<lo or mn>hi)
                {
                    cout<<"No"<<endl;
                    return;
                }
                hi=min(mx,hi);
                lo=max(mn,lo);
            }
            for(int j=L;j<=R;j++)
            {
                g[j]=hi;
            }
            cur=hi;
        }
        else
        {
            auto [mn,mx]=info[i].second;
            if(mn>cur)
            {
                cout<<"No"<<endl;
                return;
            }
            cur=min(cur-1,mx);
            g[i]=cur;
        }
    }


    for(int i=0;i<n;i++)
    {
        int idx=info[i].first.second;
        int z=g[i]-info[i].second.first;
        // cout<<"debug:"<<idx<<' '<<g[i]<<endl;
        for(int j=0;j<m;j++)
        {
            if(a[idx][j]==-1)
            {
                a[idx][j]=min(k,z);
                z-=a[idx][j];
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<a[i][j]<<' ';
        }
        cout<<endl;
    }
}
int32_t main()
{
    int t;cin>>t;
    while(t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 64ms
memory: 4240kb

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)