QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#638178#9422. Two-star ContestvictoryACWA 28ms4560kbC++141.6kb2024-10-13 15:07:322024-10-13 15:07:32

Judging History

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

  • [2024-10-13 15:07:32]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:4560kb
  • [2024-10-13 15:07:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
#define endl '\n'
const int N=2e5+10;
const double eps=1e-9;
struct node
{
	ll x,sum,id,l,r;
}b[N];
bool cmp(node x,node y)
{
	return x.x>y.x;
}
void solve()
{
	ll n,m,k;
	cin>>n>>m>>k;
	map<ll,ll> mp;
	vector<vector<ll>> a(n+1,vector<ll>(m+10,0));
	for(int i=1;i<=n;i++)
	{
		ll s;
		cin>>s;
		mp[s]++;
		b[i].id=i,b[i].x=s;
		ll sum=0,cnt=0;
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]!=-1) sum+=a[i][j];
			else cnt++;
		}
		b[i].l=sum;
		b[i].r=sum+cnt*k;
	}
	sort(b+1,b+1+n,cmp);
	ll maxx=1e18;
	map<ll,ll> mmp;
	for(int i=1;i<=n;i+=mp[b[i].x])
	{
		ll c=mp[b[i].x];
		ll mx=maxx,mn=0;
		for(int j=i;j<=i+c-1;j++)
		{
			if(b[j].r<mn||b[j].l>mx)
			{
				cout<<"No"<<endl;
				return;
			}
			mx=min(mx,b[j].r);
			mn=max(mn,b[j].l);
			if(mn>mx) 
			{
				cout<<"No"<<endl;
				return;
			}
		}
		maxx=mx-1;
		mmp[b[i].x]=mx;
	}
	for(int i=1;i<=n;i++)
	{
		ll id=b[i].id;
		ll x=mmp[b[i].x];
		ll ssm=0;
		for(int j=1;j<=m;j++)
		{
			if(a[id][j]!=-1) ssm+=a[id][j];
		}
		x-=ssm;
		for(int j=1;j<=m;j++)
		{
			if(a[id][j]==-1)
			{
				if(!x) a[id][j]=0;
				if(x<k)
				{
					a[id][j]=x;
					x-=x;
				}
				else if(x>=k)
				{
					a[id][j]=k;
					x-=k;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j]<<' ';
		}
		cout<<endl;
	}
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int _=1;
	cin>>_;
	while(_--)
	{
		solve();	
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3860kb

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:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 4560kb

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 
No
Yes
72716304 58625957 66436933 0 45419040 55642613 
72716304 62712753 72716304 21765515 56544945 12385026 
Yes
975402536 975402536 975402536 975402536 975402536 372427170 0 0 0 
975402536 975402536 975402536 975402536 211610436 944794448 67558026 0 0 
788675016 424172233 162632...

result:

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