QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#659746 | #9422. Two-star Contest | Pollock | WA | 31ms | 5164kb | C++17 | 3.2kb | 2024-10-19 21:45:46 | 2024-10-19 21:45:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define TEXT freopen("azerah.in","r",stdin); freopen("azerah.out","w",stdout);
#define testcase int TT; cin >> TT; for (int tc = 1; tc <= TT; tc++)
#define POL(i,n) for (int i = 0 ; i < n ; ++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define F first
#define S second
//#define endl "\n"
typedef pair<int,int>PL;
void solve()
{
ll n,m,k;
cin >> n >> m >> k;
vector<pair<ll,pair<vector<ll>,ll>>>v;
for(ll i=1; i<=n; i++)
{
ll s;
cin >> s;
vector<ll>vk;
for(ll j=1; j<=m; j++)
{
ll ij;
cin >> ij;
vk.pb(ij);
}
v.pb({s,{vk,i}});
}
sort(v.begin(),v.end());
vector<pair<ll,vector<ll>>>ans;
ll mx=-1;
for(ll i=0; i<n; i++)
{
vector<ll>vt=v[i].second.first;
vector<ll>res;
ll sm=0;
for(auto it:vt)
{
if(it!=-1)
{
sm+=it;
}
}
for(auto it:vt)
{
if(it==-1)
{
if(i==0)
{
if(sm>mx)
{
res.pb(0);
}
else
{
ll mn=min(k,mx-sm+1);
res.pb(mn);
sm+=mn;
}
}
else
{
if(v[i].first==v[i-1].first)
{
if(sm>=mx)
{
res.pb(0);
}
else
{
ll mn=min(k,mx-sm+1);
res.pb(mn);
sm+=mn;
}
}
else
{
if(sm>mx)
{
res.pb(0);
}
else
{
ll mn=min(k,mx-sm+1);
res.pb(mn);
sm+=mn;
}
}
}
}
else
{
res.pb(it);
}
}
ans.pb({v[i].second.second,res});
if(i>0 && v[i].first>v[i-1].first && sm<=mx)
{
cout << "No" << endl;
return;
}
mx=max(mx,sm);
}
cout << "Yes" << endl;
sort(ans.begin(),ans.end());
for(auto it:ans)
{
vector<ll>dk=it.second;
for(auto ik:dk)
{
cout << ik << " ";
}
cout << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
testcase
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
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 3 0 5 0 5 3 4 0 4 No Yes 1 2 3 4 5 6 No Yes 1 0 0 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 31ms
memory: 5164kb
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 96295 96295 56792 96295 75462 0 19527 0 12828 30553 40825 67577 91517 77952 55631 63781 29385 96295 96295 96295 750 96295 25350 0 Yes 0 0 66436933 0 45419040 55642613 14090348 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 9...
result:
wrong answer Participant cannot satisfy the constraint. (test case 30)