QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693255#9422. Two-star Contestchenjue#WA 30ms43680kbC++201.2kb2024-10-31 15:49:312024-10-31 15:49:34

Judging History

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

  • [2024-10-31 15:49:34]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:43680kb
  • [2024-10-31 15:49:31]
  • 提交

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;
	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(sum>ans){
			ans=sum;
			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;
				}
			}
			ans=sum;
		}
		else{
			cout<<"No"<<endl;return ;
		}
	}
	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;
}

详细

Test #1:

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

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: 30ms
memory: 43680kb

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 75462 0 19527 0 
12828 30553 40825 67577 91517 77952 55631 63781 
29385 96295 96295 96295 750 96295 25350 0 
Yes
0 0 66436933 0 45419040 55642613 
14090348 62712753 0 21765515 56544945 12385026 
Yes
975402536 975402536 9...

result:

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