QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725956#9422. Two-star ContestwsxcbWA 1ms3608kbC++171.3kb2024-11-08 20:54:142024-11-08 20:54:14

Judging History

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

  • [2024-11-08 20:54:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-11-08 20:54:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
typedef vector<vector<ll>> Mat;
#define int long long
const int N=1e6+10,mod=1e9+7,inf=1e9+1,P=998244353;
const double pi=acos(-1.0),esp=1e-9;
const ll INF=1e18;
void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	vector<vector<int>>ans(n+1,vector<int>(m+1));
	vector<int>p(n+1),v(n+1);
	vector<ll>s(n+1);
	for(int i=1;i<=n;i++){
		p[i]=i;
		cin>>v[i];
		for(int j=1;j<=m;j++){
			cin>>ans[i][j];
			if(ans[i][j]!=-1)s[i]+=ans[i][j];
			//cout<<ans[i][j]<<' ';
		}
		//cout<<'\n';
	}
	sort(p.begin()+1,p.end(),[&](int x,int y){
		return v[x]<v[y];
	});
	v[0]=v[p[1]];
	for(int i=1;i<=n;i++){
		int x=p[i];
		ll g=s[p[i-1]];
		if(v[p[i-1]]!=v[p[i]])
			g++;
		for(int j=1;j<=m;j++){
			if(ans[x][j]==-1){
				ll k1=min(max(0ll,g-s[x]),1ll*k);
				//cout<<k1<<' ';
				s[x]+=k1;
				ans[x][j]=k1;
			}
		}
		//cout<<'\n';
		if(s[x]<g){
			cout<<"NO\n";
			return ;
		}
	}
	cout<<"YES\n";
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
		cout<<ans[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: 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 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:

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