QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693356#9422. Two-star Contestchenjue#WA 0ms42684kbC++201.7kb2024-10-31 16:00:542024-10-31 16:00:54

Judging History

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

  • [2024-10-31 16:00:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:42684kb
  • [2024-10-31 16:00:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
const int N=1e6+10;
int n,m,k;
struct node{
	int id;
	int st;
	vector<int>p;
	
}a[N];
bool cmp(node a, node b){
	return a.st < b.st;
}
bool cmp1(node a, node b){
	return a.id < b.id;
}
void solve(){
	cin>>n>>m>>k;
	rep(i,1,n){
		a[i].p.clear();
		a[i].id=i;
		cin>>a[i].st;
		rep(j,1,m){
			int x;cin>>x;
			a[i].p.push_back(x);
		}
	}
	sort(a+1,a+1+n,cmp);
	int ans=0;
	int ans2=0;
	int star=a[1].st;
	for(auto &it:a[1].p){
		if(it==-1){
			it=0;
		}
		ans+=it; 
	}
	rep(i,2,n){
		int e=0;
		int sum=0;
		for(auto &it:a[i].p){
			if(it==-1){
				e++;
			}
			else
			sum+=it;
		}
		if(star!=a[i].st){
			ans=ans2;
			if(sum>ans){
				for(auto &it:a[i].p){
					if(it==-1){
						it=0;
					}
				}
			}
			else if(sum+e*k>ans){
				int d=ans+1;
				for(auto &it:a[i].p){
					if(it==-1){
						it=min(k,d-sum);
						sum+=it;
					}
				}
			}
			else{
				cout<<"No"<<endl;return ;
			}
			ans2=sum;//ans ans2 
		}
		else{
			if(sum>ans){
				for(auto &it:a[i].p){
					if(it==-1){
						it=0;
					}
				}
			}
			else if(sum+e*k>ans){
				int d=ans+1;
				for(auto &it:a[i].p){
					if(it==-1){
						it=min(k,d-sum);
						sum+=it;
					}
				}
			}
			else{
				cout<<"No"<<endl;return ;
			}
			ans2=max(sum,ans);
		}
		
	}
	cout<<"Yes"<<endl;
	sort(a+1,a+1+n,cmp1);
	rep(i,1,n){
		for(auto &it:a[i].p){
			cout<<it<<' ';
		}
		cout<<endl;
	}
}
signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int _=1;
	cin>>_;
	while(_--)solve();
	return 0;
}
/*
1
3 4 5
5 1 3 -1 -1
2 -1 5 -1 5
2 3 -1 -1 4


*/ 

詳細信息

Test #1:

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

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 4 0 
0 5 0 5 
3 0 0 4 
Yes
5 0 0 
10 10 10 
Yes
1 2 3 
4 5 6 
Yes
1 2 3 
4 5 6 
Yes
1 0 0 
0 0 0 

result:

wrong answer Participant cannot satisfy the constraint. (test case 1)