QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676154 | #9422. Two-star Contest | Bulonte | WA | 0ms | 25488kb | C++23 | 3.0kb | 2024-10-25 20:28:48 | 2024-10-25 20:28:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 4e5+5;
struct sb
{
int star;
vector<int> a;
int cnt = 0;
int sum = 0;
int index;
}arr[N];
bool cmp(sb aa,sb bb){return aa.star<bb.star;}
bool cmp1(sb aa,sb bb){return aa.index<bb.index;}
int lastsum = 0;
bool check(int n,int k)
{
lastsum = arr[1].sum;
for(int i = 1;i<=n;i++)
{
if(arr[i].sum + arr[i].cnt*k < lastsum)
{
return false;
}
else
{
if(arr[i].cnt == 0)
{
lastsum = max(arr[i].sum,lastsum+1);
}
else
{
int len = arr[i].a.size();
for(int j = 0;j<len;j++)
{
int cha = lastsum - arr[i].sum;
int tmp = cha%arr[i].cnt;
if(i == 1)
{
if(arr[i].a[j] == -1) arr[i].a[j] = 0;
}
else
{
if(tmp == 0)
{
if(arr[i].a[j] == -1) arr[i].a[j] = cha/arr[i].cnt;
}
else
{
int count = 0;
if(count == arr[i].cnt - 1)
{
if(arr[i].a[j] == -1) arr[i].a[j] = cha/arr[i].cnt+tmp;
}
else
{
if(arr[i].a[j] == -1) arr[i].a[j] = cha/arr[i].cnt;
}
}
}
}
lastsum = max(arr[i].sum,lastsum+1);
}
}
}
return true;
}
void solve()
{
int n,m,k;cin>>n>>m>>k;
lastsum = 0;
for(int i = 1;i<=n;i++){arr[i].a.clear();arr[i].sum = 0;arr[i].cnt = 0;}
for(int i = 1;i<=n;i++)
{
cin>>arr[i].star;
arr[i].index = i;
for(int k = 1;k<=m;k++)
{
int tmp;cin>>tmp;
if(tmp == -1)
{
arr[i].cnt ++;
}
else
{
arr[i].sum += tmp;
}
arr[i].a.push_back(tmp);
}
}
sort(arr+1,arr+1+n,cmp);
if(check(n,k) == false)
{
cout<<"No"<<endl;
return;
}
else
{
sort(arr+1,arr+1+n,cmp1);
cout<<"Yes"<<endl;
for(int i = 1;i<=n;i++)
{
int len = arr[i].a.size();
for(int j = 0;j<len;j++)
{
cout<<arr[i].a[j]<<" ";
}
cout<<endl;
}
}
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 25488kb
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 Yes 1 2 3 4 5 6 No Yes 0 0 0 0 0 0
result:
wrong answer Participant cannot satisfy the constraint. (test case 5)