QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659598 | #7857. (-1,1)-Sumplete | oldsea | RE | 0ms | 3864kb | C++23 | 1.7kb | 2024-10-19 20:54:21 | 2024-10-19 20:54:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 i128;
const ll yu = 1e9+7;
const int N = 4e5+10;
using PII=pair<ll,ll>;
ll row[4005]={0};
ll col[4005]={0};
void solve()
{
ll n;
cin >> n;
priority_queue<PII> q;
vector<vector<ll>> ans(n+1,vector<ll>(n+1,-1));
vector<vector<ll>> arr(n+1,vector<ll>(n+1,1));
for (int i=1;i<=n;i++)
{
string s;
cin >> s;
for (int j=0;j<s.size();j++)
{
if (s[j]=='-') row[i]++,col[j+1]++,arr[i][j+1]=-1;
}
}
ll f=1;
for (int i=1;i<=n;i++)
{
ll a;
cin >> a;
row[i]+=a;
if (row[i]>n) f=0;
}
for (int i=1;i<=n;i++)
{
ll a;cin >> a;
col[i]+=a;
if (col[i]>n) f=0;
if (col[i]>0) q.push({col[i],i});
}
if (!f)
{
cout << "No\n";
return;
}
for (int i=1;i<=n;i++)
{
ll ne=row[i];
vector<PII> ar;
while(ne--) ar.push_back(q.top()),q.pop();
for (int j=0;j<ar.size();j++)
{
ll v=ar[j].first;
ll x=ar[j].second;
v--;
ans[i][x]=1;
if (v>0) q.push({v,x});
}
}
if (q.size()) f=0;
if (!f)
{
cout << "No\n";
}
else
{
cout << "Yes\n";
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
cout << (ans[i][j]==arr[i][j]);
}
cout << endl;
}
}
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t=1;
//cin >> t;
while (t--)
{
solve();
}
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 111 111
result:
ok n=3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: -100
Runtime Error
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
Yes 100 110 111