QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751943#9422. Two-star ContestendeavorHaoWA 68ms51524kbC++203.5kb2024-11-15 21:22:052024-11-15 21:22:10

Judging History

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

  • [2024-11-15 21:22:10]
  • 评测
  • 测评结果:WA
  • 用时:68ms
  • 内存:51524kb
  • [2024-11-15 21:22:05]
  • 提交

answer


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
struct Node
{
    int rate;
    vector<int>v;
    int sum;
    int id;
}nd[N];
bool cmp(Node x,Node y)
{
    return x.rate<y.rate;
}
bool cmp2(Node x,Node y)
{
    return x.id<y.id;
}
map<int,int>mp;
void solve(){
    int n,m,k;
    mp.clear();
    cin>>n>>m>>k;
    int flag=1;
    for(int i=0;i<n;i++)nd[i].v.clear();
    for(int i=0;i<n;i++)
    {
        cin>>nd[i].rate;
        for(int j=0;j<m;j++)
        {
            int t;
            cin>>t;
            nd[i].v.push_back(t);
        }
        nd[i].id=i;
    }
    sort(nd,nd+n,cmp);
    for(int i=0;i<n;i++)
    {
        int sum=0;
        for(int j=0;j<m;j++)
        {
            if(nd[i].v[j]!=-1)sum+=nd[i].v[j];
        }
        nd[i].sum=sum;
    }
    int last=-1;
    for(int i=0;i<m;i++)
    if(nd[0].v[i]==-1)nd[0].v[i]=0;
    mp[nd[0].rate]=nd[0].sum;
    for(int i=1;i<n;i++)
    {
        int t=nd[i].sum-mp[nd[i-1].rate];
        if(nd[i].rate!=nd[i-1].rate)
        {   
            last=i-1;
            if(t>0)
            {
                for(int j=0;j<m;j++)
                {
                if(nd[i].v[j]==-1)
                    nd[i].v[j]=0;
                }
                t=0;
                mp[nd[i].rate]=max(mp[nd[i].rate],nd[i].sum);
            }
            else
            {
                t=abs(t);
                t++;
                for(int j=0;j<m;j++)
                {
                    if(nd[i].v[j]==-1)
                    {
                        if(t>k)
                        {
                            nd[i].v[j]=k;
                            nd[i].sum+=k;
                            t-=k;
                        }
                        else 
                        {
                            nd[i].v[j]=t;
                            nd[i].sum+=t;
                            t=0;
                        }
                    }
                }
                mp[nd[i].rate]=max(mp[nd[i].rate],nd[i].sum);
            }
        }
        else
        {
            if(last==-1)
            {
                t=0;
                for(int j=0;j<m;j++)if(nd[i].v[j]==-1)nd[i].v[j]=0;
                mp[nd[i].rate]=max(mp[nd[i].rate],nd[i].sum);
            }
            else
            {
                t=nd[i].sum-mp[nd[last].rate];
                t=abs(t);
                t++;
                for(int j=0;j<m;j++)
                {
                    if(nd[i].v[j]==-1)
                    {
                        if(t>k)
                        {
                            nd[i].v[j]=k;
                            nd[i].sum+=k;
                            t-=k;
                        }
                        else 
                        {
                            nd[i].v[j]=t;
                            nd[i].sum+=t;
                            t=0;
                        }
                    }
                }
                mp[nd[i].rate]=max(mp[nd[i].rate],nd[i].sum);
            }
        }
        if(t)flag=0;
    }

    if(!flag)cout<<"No"<<endl;
    else
    {
        sort(nd,nd+n,cmp2);
        cout<<"Yes"<<endl;
        for(int i=0;i<n;i++) 
        {
            for(int j=0;j<m;j++)
            {
                cout<<nd[i].v[j]<<" ";
            }
            cout<<endl;
        }
    }

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

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 50680kb

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

result:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 68ms
memory: 51524kb

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
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 97540253...

result:

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