QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695644 | #9422. Two-star Contest | HQLF | WA | 0ms | 3756kb | C++20 | 3.3kb | 2024-10-31 20:30:33 | 2024-10-31 20:30:34 |
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: 0
Wrong Answer
time: 0ms
memory: 3756kb
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:
wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)