QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643436#9422. Two-star Contestdqw#WA 55ms4240kbC++233.1kb2024-10-15 21:11:492024-10-15 21:11:51

Judging History

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

  • [2024-10-15 21:11:51]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:4240kb
  • [2024-10-15 21:11:49]
  • 提交

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;
            if(L==0)
            {
                for(int j=L;j<=R;j++)
                {
                    auto [mn,mx]=info[j].second;
                    g[j]=mx;
                    hi=min(hi,mx);
                }
                cur=hi;
            }
            else if(R==0)
            {
                for(int j=L;j<=R;j++)
                {
                    auto [mn,mx]=info[j].second;
                    g[j]=mn;
                    lo=max(lo,mn);
                }
                if(lo>=cur)
                {
                    cout<<"No"<<endl;
                    return;
                }
            }
            else
            {
                for(int j=L;j<=R;j++)
                {
                    auto [mn,mx]=info[j].second;
                    lo=max(lo,mn);
                    hi=min(hi,mx);
                }
                if(lo>=cur)
                {
                    cout<<"No"<<endl;
                    return;
                }
                cur=min(cur-1,hi);
                for(int j=L;j<=R;j++)
                {
                    auto [mn,mx]=info[j].second;
                    g[j]=cur;
                }
            }
        }
        else
        {
            auto [mn,mx]=info[i].second;
            if(mn>cur-1)
            {
                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();
    }
}

详细

Test #1:

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

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: 55ms
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 
Yes
96295 849 96295 96295 33907 7926 9461 70117 
96295 96295 56792 96295 96295 96295 19527 96295 
12828 30553 40825 67577 91517 77952 55631 63781 
29385 96295 96295 96295 750 92125 0 0 
Yes
72716304 72716304 66436933 72716304 45419040 55642613 
72716304 62712753 72716304 21765515 ...

result:

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