QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#675404 | #9422. Two-star Contest | Bulonte | WA | 29ms | 26720kb | C++23 | 2.3kb | 2024-10-25 18:31:07 | 2024-10-25 18:31:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 4e5+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++) {node[i].a.clear();node[i].cnt = 0;node[i].sum = 0;}
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: 100
Accepted
time: 3ms
memory: 25400kb
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: 29ms
memory: 26720kb
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 7657 7657 56792 7657 7657 7657 19527 7659 12828 30553 40825 67577 91517 77952 55631 63781 29385 15354 15354 15354 750 15354 15354 15357 Yes 0 0 66436933 0 45419040 55642613 7045174 62712753 7045174 21765515 56544945 12385026 Yes 374573029 ...
result:
wrong answer Participant cannot satisfy the constraint. (test case 2)