QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687957#9422. Two-star Contesteden369WA 73ms4480kbC++172.3kb2024-10-29 22:12:262024-10-29 22:12:27

Judging History

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

  • [2024-10-29 22:12:27]
  • 评测
  • 测评结果:WA
  • 用时:73ms
  • 内存:4480kb
  • [2024-10-29 22:12:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
struct node
{
    int s;
    vector<int> v;
    int id;
    int ze;
    int sum;
};
bool cmp1(node a,node b)
{
    return a.s<b.s;
}
bool cmp2(node a,node b)
{
    return a.id<b.id;
}
void solve()
{
    int n,m,t;
    cin>>n>>m>>t;
    vector<node> a(n);
    for(int i=0;i<n;i++)
    {
        a[i].id=i;
        cin>>a[i].s;
        int nu=0;
        for(int j=0;j<m;j++)
        {
            int k;
            cin>>k;
            if(k==-1)
            {
                nu++;
            }
            if(k!=-1)
            a[i].sum+=k;
            a[i].v.push_back(k);
        }
        a[i].ze=nu;
    }
    sort(a.begin(),a.end(),cmp1);
    /*for(int i=0;i<n;i++)
    {
        cout<<a[i].id<<" ";
    }*/
    cout<<endl;
    int mas=0;
    int ss=0;
    for(int i=0;i<n;i++)
    {
        if(ss==a[i].s)
        {
            mas=max(mas,a[i].sum);
            for(auto &b:a[i].v)
            {
                if(b==-1)
                b=0;
            }
        }
        else
        {
            int cha=a[i].sum-mas;
            int l=0;
            while(l<a[i].v.size())
            {
                if(cha<=0)
                {
                if(a[i].v[l]==-1)
                {
                    a[i].v[l]=min(-cha+1,t);
                    cha+=a[i].v[l];
                    a[i].sum+=a[i].v[l];
                }
                l++;
                }
                else
                {
                    if(a[i].v[l]==-1)
                    {
                        a[i].v[l]=0;
                        cha+=a[i].v[l];
                    }
                l++;
                }
            }
            if(cha<=0)
            {
                cout<<"No"<<endl;
                return ;
            }
            mas=a[i].sum;
            ss=a[i].s;
        }
        //cout<<"mas="<<mas<<" "<<endl;
    }
    sort(a.begin(),a.end(),cmp2);
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)
    {
        for(auto b:a[i].v)
        cout<<b<<" ";
        cout<<endl;
    }

}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
2 0 0 
1 0 0 

result:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 73ms
memory: 4480kb

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:


No

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 0 0 0 750 0 0 0 

Yes
0 0 66436933 0 45419040 55642613 
0 62712753 0 21765515 56544945 12385026 

Yes
975402536 975402536 975402536 975402536 975402536 248560376 ...

result:

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