QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675372#9422. Two-star ContestBulonteWA 0ms9012kbC++232.2kb2024-10-25 18:26:422024-10-25 18:26:43

Judging History

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

  • [2024-10-25 18:26:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9012kb
  • [2024-10-25 18:26:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 

const int N = 1e5+5;

struct NODE
{
	int s;
	vector<int> a;
	int sum = 0;
	int cnt = 0;
	int index;
}node[N];

bool cmp(NODE aa,NODE bb){return aa.s<bb.s;}
bool cmp1(NODE aa,NODE bb){return aa.index<bb.index;}

bool check(int n,int k)
{
	int begin = 1;
	for(int i = 1;i<=n;i++)
	{
		if(node[i].cnt == 0)
		{
			if(node[i].sum < i-begin+node[begin].sum)
			{
				return false;
			}
			else
			{
				begin = i;
			}
		}
		if((node[i].sum + node[i].cnt*k )<(i-begin+node[begin].sum))
		{
			return false;
		}
	}
	return true;
}

void solve()
{
	int n,m,k;cin>>n>>m>>k;
	for(int i = 1;i<=n;i++)
	{
		cin>>node[i].s;
		node[i].index = i;
		for(int j = 1;j<=m;j++)
		{
			int tmp;cin>>tmp;
			if(tmp == -1)
			{
				node[i].cnt ++;
			}
			else
			{
				node[i].sum += tmp;
			}
            node[i].a.push_back(tmp);
		}
	}
	
	sort(node+1,node+1+n,cmp);

	if(check(n,k) == false)
	{
		cout<<"No"<<endl;
		return ;
	}
	else
	{
		for(int i = 1;i<=n;i++)
		{
			if(node[i].cnt == 0) continue;
			if(i == 1)
			{
				for(int j = 0;j<m;j++)
				{
					if(node[i].a[j] == -1)
					{
						node[i].a[j] = 0;
					}
				}
			}
			else
			{
				int cha = node[1].sum+i-1-node[i].sum;
				if(cha % node[i].cnt == 0)
				{
					for(int j = 0;j<m;j++)
					{
						if(node[i].a[j] == -1)
						{
							node[i].a[j] = cha/node[i].cnt;
						}
					}
				}
				else
				{
					int count = 0;
					int tmp = cha/node[i].cnt;
					for(int j = 0;j<m;j++)
					{
						if(node[i].a[j] == -1)
						{
							node[i].a[j] = tmp;
							count ++;
							if(count == node[i].cnt-1)
							{
								tmp += cha%node[i].cnt;
							}
						}
					}
				}
			}
		}
		
		sort(node+1,node+1+n,cmp1);
        cout<<"Yes"<<endl;
		for(int i = 1;i<=n;i++)
		{
			for(int j = 0;j<m;j++)
			{
				cout<<node[i].a[j]<<" ";
			}
			cout<<endl;
		}

        for(int i = 1;i<=n;i++) {node[i].a.clear();node[i].cnt = 0;node[i].sum = 0;}
		return;
		
	}
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t;cin>>t;
    while(t--) solve();
}

詳細信息

Test #1:

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

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

result:

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