QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643549 | #9422. Two-star Contest | dqw# | Compile Error | / | / | C++23 | 3.1kb | 2024-10-15 21:44:11 | 2024-10-15 21:44:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n,m,k;cin>>n>>m>>k;
vector<pair<pair<int,int>,pair<int,int>>>info(n);
vector<vector<int>>a(n,vector<int>(m));
for(int i=0;i<n;i++)
{
int s;cin>>s;
info[i].first.first=s;
int sum=0,cnt=0;
for(int j=0;j<m;j++)
{
int f;cin>>f;
a[i][j]=f;
if(f==-1)cnt++;
else sum+=f;
}
int mx=sum+cnt*k,mn=sum;
info[i].second={mn,mx};
info[i].first.second=i;
}
sort(info.rbegin(),info.rend());
vector<int>g(n);
int cur=info[0].second.second;
g[0]=cur;
for(int i=1;i<n;i++)
{
if(info[i].first.first==info[i-1].first.first)
{
int L=i-1;
int R=i;
while(i+1<n and info[i].first.first==info[i+1].first.first)
{
R++;
i++;
}
int hi=1e18,lo=0;
if(L==0)
{
for(int j=L;j<=R;j++)
{
auto [mn,mx]=info[j].second;
g[j]=mx;
hi=min(hi,mx);
}
cur=hi;
}
else if(R==n-1)
{
for(int j=L;j<=R;j++)
{
auto [mn,mx]=info[j].second;
g[j]=mn;
lo=max(lo,mn);
}
if(lo>=cur)
{
cout<<"No"<<endl;
return;
}
}
else
{
for(int j=L;j<=R;j++)
{
auto [mn,mx]=info[j].second;
lo=max(lo,mn);
hi=min(hi,mx);
}
if(lo>=cur)
{
cout<<"No"<<endl;
return;
}
int p=cur-1;
for(int j=L;j<=R;j++)
{
auto [mn,mx]=info[j].second;
g[j]=min(p,mx);
cur=min(cur,g[j]);
}
}
}
else
{
auto [mn,mx]=info[i].second;
if(mn>=cur)
{
cout<<"No"<<endl;
return;
}
cur=min(cur-1,mx);
g[i]=cur;
}
}
for(int i=0;i<n;i++)
{
int idx=info[i].first.second;
int z=g[i]-info[i].second.first;
// cout<<"debug:"<<idx<<' '<<g[i]<<endl;
for(int j=0;j<m;j++)
{
if(a[idx][j]==-1)
{
a[idx][j]=min(k,z);
z-=a[idx][j];
}
}
}
cout<<"Yes"<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout<<a[i][j]<<' ';
}
cout<<endl;
}
}
int32_t main()
{
int t;cin>>t;
while(t--)
{
solve();
}
}.
Details
answer.code:132:2: error: expected unqualified-id before ‘.’ token 132 | }. | ^