QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692223#9422. Two-star ContestcoolarecWA 0ms3836kbC++201.7kb2024-10-31 14:07:372024-10-31 14:07:38

Judging History

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

  • [2024-10-31 14:07:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-10-31 14:07:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include"algo/debug.h"
#else
#define debug(x) 42
#endif
#define int long long
void solve(){
    int n,m,k;cin>>n>>m>>k;
    map<int,vector<int>> pos;
    vector<vector<int>> a(n+1,vector<int>(m+1));
    vector<int> rk;
    for(int i=1;i<=n;i++){
        int val;cin>>val;
        pos[val].push_back(i);
        rk.push_back(val);
        for(int j=1;j<=m;j++)cin>>a[i][j];
    }
    sort(rk.begin(),rk.end());
    rk.erase(unique(rk.begin(),rk.end()),rk.end());
    reverse(rk.begin(),rk.end());
    int up=1e18;
    auto getmaxx=[&](int x){
        int ans=0;
        for(int i=1;i<=m;i++){
            if(a[x][i]==-1)ans+=k;
            else ans+=a[x][i];
        }
        return ans;
    };
    auto getminn=[&](int x){
        int ans=0;
        for(int i=1;i<=m;i++){
            if(a[x][i]==-1)ans+=0;
            else ans+=a[x][i];
        }
        return ans;
    };
    for(int i=0;i<n;i++){
        int l=0,r=1e18;
        
        for(auto x:pos[rk[i]]){
            l=max(l,getminn(x));
            r=min(r,getmaxx(x));
        }
        int tmp=min(up-1,r);
        if(tmp<l)return cout<<"NO\n",void();
        for(auto x:pos[rk[i]])a[x][0]=tmp;
        up=tmp;
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)if(a[i][j]!=-1)a[i][0]-=a[i][j];
        for(int j=1;j<=m;j++){
            if(a[i][j]==-1)a[i][j]=min(k,a[i][0]),a[i][0]-=a[i][j];
            cout<<a[i][j]<<' ';
        }
        cout<<'\n';
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int T=1;
    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3836kb

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:

wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)