QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725958#9422. Two-star ContestwsxcbWA 28ms4156kbC++171.3kb2024-11-08 20:54:582024-11-08 20:54:58

Judging History

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

  • [2024-11-08 20:54:58]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:4156kb
  • [2024-11-08 20:54:58]
  • 提交

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: 100
Accepted
time: 1ms
memory: 3556kb

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: 28ms
memory: 4156kb

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 96295 96295 96295 750 96295 25349 0 
Yes
0 0 66436933 0 45419040 55642613 
14090347 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)