QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546344 | #7857. (-1,1)-Sumplete | cyc_43346 | WA | 1ms | 5728kb | C++14 | 1.4kb | 2024-09-03 23:29:37 | 2024-09-03 23:29:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
int mp[5005][5005];
bool f[5005][5005];
int a[5005],b[5005];
bool c[5005];
struct P{
int v,i;
}p[5005];
void solve()
{
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char c;
cin>>c;
if(c=='+')
mp[i][j]=1;
else mp[i][j]=-1;
}
}
bool flag=0;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(mp[i][j]==-1){
f[i][j]=1;
a[i]++;
b[j]++;
}
}
}
for(int i=1;i<=n;i++){
if(a[i]<0||b[i]<0)flag=1;
}
if(flag){
cout<<"No\n";
return;
}
pair<int,int>p[5005];
for(int i=1;i<=n;i++)p[i].first = b[i],p[i].second=i;
for(int i=1;i<=n;i++){
sort(p+1,p+1+n);
for(int j=n;j>=1&&a[i];j--,a[i]--){
f[i][p[j].second]^=1;
if(p[j].first==0){
cout<<"No\n";
return;
}
p[j].first--;
}
}
cout<<"Yes\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cout<<f[i][j]<<" ";
}
if(i==n) break;
cout<<endl;
}
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5728kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 1 1 1 1 1 1 1 1 1
result:
wrong output format Expected EOLN