QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#676285 | #9422. Two-star Contest | Bulonte | WA | 24ms | 26588kb | C++23 | 3.0kb | 2024-10-25 20:56:25 | 2024-10-25 20:56:26 |
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;
int count = 0;
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();
int cha = lastsum - arr[i].sum;
int tmp = cha%arr[i].cnt;
for(int j = 0;j<len;j++)
{
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
{
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;
count ++;
}
}
}
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 25628kb
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 1 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 24ms
memory: 26588kb
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 60726 60726 56792 60726 60726 60726 19527 60726 12828 30553 40825 67577 91517 77952 55631 63781 29385 68421 68421 68421 750 68424 68424 68424 Yes 0 0 66436933 0 45419040 55642613 7045174 62712753 7045174 21765515 56544945 12385026 Yes 5695...
result:
wrong answer Participant cannot satisfy the constraint. (test case 4)