QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692193#9422. Two-star Contestyld#WA 31ms5340kbC++202.5kb2024-10-31 14:01:452024-10-31 14:01:45

Judging History

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

  • [2024-10-31 14:01:45]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:5340kb
  • [2024-10-31 14:01:45]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long 
#define endl '\n'
using namespace std;
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<int,vector<int>>> a(n+1);
    vector<pair<int,int>> b(n+1);
    vector<int> X;
    for(int i=1;i<=n;i++)
    {
        vector<int> tmp;
        int rk;cin>>rk;
        X.push_back(rk);
        a[i].first=rk;
        for(int j=1;j<=m;j++)
        {
            int x;cin>>x;
            tmp.push_back(x);
        }
        a[i].second=tmp;
    }
    sort(X.begin(),X.end());
    X.erase(unique(X.begin(),X.end()),X.end());
    for(int i=1;i<=n;i++)
    {
        a[i].first=lower_bound(X.begin(),X.end(),a[i].first)-X.begin()+1;
        b[i].first=a[i].first;
        b[i].second=i;
    }
    sort(a.begin()+1,a.end(),greater<>());
    sort(b.begin()+1,b.end(),greater<>());
    // for(int i=1;i<=n;i++)
    // {
    //     cout<<a[i].first<<endl;
    //     for(auto x:a[i].second) cout<<x<<' ';
    //     cout<<endl;
    // }
    vector<pair<int,int>> s(n+1,{1e18,0});
    for(int i=1;i<=n;i++)
    {
        int sum=0,num=0;
        for(auto x:a[i].second)
        {
            if(x==-1) num++;
            else sum+=x; 
        }
        s[a[i].first].first=min(s[a[i].first].first,sum);
        s[a[i].first].second=max(s[a[i].first].second,sum+num*k);
    }
    // for(int i=1;i<=n;i++) cout<<s[i].first<<' '<<s[i].second<<endl;
    int len=X.size();
    for(int i=len-1;i>=1;i--)
    {
        if(s[i].first>s[i+1].second-1){cout<<"No\n";return;}
        s[i].second=min(s[i].second,s[i+1].second-1);
    }
    
    // for(int i=1;i<=n;i++) cout<<s[i].first<<' '<<s[i].second<<endl;
    for(int i=1;i<=n;i++)
    {
        int num=s[a[i].first].second;
        for(auto x:a[i].second)
            if(x!=-1) num-=x;
        for(auto &x:a[i].second)
        {
            if(x==-1)
            {
                if(num>=k)
                {
                    num-=k;
                    x=k;
                }
                else
                {
                    x=num;
                    num=0;
                }
            }
        }
    }
    cout<<"Yes\n";
    vector<vector<int>> ans(n+1);
    for(int i=1;i<=n;i++)
    {
        vector<int> tmp=a[i].second;
        ans[b[i].second]=tmp;
    }
    for(int i=1;i<=n;i++)
    {
        for(auto x:ans[i]) cout<<x<<' ';
        cout<<endl;
    }
}
signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 31ms
memory: 5340kb

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 96295 96295 96295 
Yes
72716304 72716304 66436933 72716304 45419040 55642613 
72716304 62712753 72716304 2...

result:

wrong answer Participant has modified p_{0, 0}. Expecting 9 but found 25. (test case 5)