QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695652 | #9422. Two-star Contest | HQLF | WA | 32ms | 4688kb | C++20 | 3.3kb | 2024-10-31 20:31:38 | 2024-10-31 20:31:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ldb=long double;
const long long inf=0x3f3f3f3f3f3f3f3f;
const ll mod=1000000007;
struct node
{
ll s,l,r;
bool operator<(const node &x)const
{
if(s==x.s)return r<x.r;
return s<x.s;
}
ll bh;
ll cnt1;
};
void solve()
{
ll n,m,k;
cin>>n>>m>>k;
node a[n+10];
ll b[n+10][m+10];
for(ll i=1;i<=n;i++)
{
ll l=0;
ll r=0;
ll cnt1=0;
cin>>a[i].s;
for(ll j=1;j<=m;j++)
{
ll x;
cin>>x;
b[i][j]=x;
if(x==-1)
{
l+=0;
r+=k;
cnt1++;
}
else
{
l+=x;
r+=x;
}
}
a[i].l=l;
a[i].r=r;
a[i].bh=i;
a[i].cnt1=cnt1;
}
sort(a+1,a+1+n);
deque<pair<ll,ll>>q;
for(ll i=n;i>=1;i--)
{
//a[i];
if(q.empty())
{
q.push_back({a[i].s,a[i].r});
}
else if(!q.empty())
{
pair<ll,ll>tp=q.front();
if(a[i].s==tp.first)
{
q.push_front({a[i].s,a[i].r});
}
else if(a[i].s<tp.first)
{
if(a[i].r<tp.second)
{
q.push_front({a[i].s,a[i].r});
}
else if(a[i].r==tp.second)
{
if(a[i].l==a[i].r)
{
printf("No\n");
return;
}
else if(a[i].l<a[i].r)
{
q.push_front({a[i].s,a[i].r-1});
}
}
else if(a[i].r>tp.second)
{
if(a[i].l>=tp.second)
{
printf("No\n");
return;
}
else if(a[i].l<tp.second)
{
q.push_front({a[i].s,tp.second-1});
}
}
}
}
}
printf("Yes\n");
for(ll i=1;i<=n;i++)
{
pair<ll,ll>tp=q.front();
q.pop_front();
ll x=tp.second-a[i].l;
ll t=floor(ldb(x)/ldb(k));
ll yu=x-t*k;
ll bh=a[i].bh;
for(ll j=1;j<=m;j++)
{
if(b[bh][j]==-1)
{
if(t>=1)
{
t--;
b[bh][j]=k;
}
else if(t==0)
{
if(yu!=0)
{
b[bh][j]=yu;
yu=0;
}
else b[bh][j]=0;
}
}
}
}
for(ll i=1;i<=n;i++)
{
for(ll j=1;j<=m;j++)
{
printf("%lld ",b[i][j]);
}
printf("\n");
}
}
int main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
ll _=1;
cin>>_;
while(_--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
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: 32ms
memory: 4688kb
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 96295 849 96295 96295 33907 7926 9461 70117 96295 96295 56792 96295 96295 96295 19527 96295 12828 30553 40825 67577 91517 77952 55631 63781 29385 96295 96295 96295 750 96295 96295 96295 Yes 72716304 72716304 66436933 72716304 45419040 55642613 72716304 62712753 72716304 2...
result:
wrong answer Participant cannot satisfy the constraint. (test case 7)