QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#575850 | #7857. (-1,1)-Sumplete | tosania | WA | 1ms | 5932kb | C++14 | 1.1kb | 2024-09-19 17:01:53 | 2024-09-19 17:01:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4e3+5;
int T;
inline int read(){
int al=0,fh=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
fh=-1;
ch=getchar();
}
while(ch<='9'&&ch>='0'){
al=al*10+ch-'0';
ch=getchar();
}
return al*fh;
}
int n,a[N],cho[N][N];
char str[N][N];
struct node
{
int i,z;
}b[N];
bool cmp(node a,node b){
return a.z>b.z;
}
signed main(){
n=read();
for(int i=0;i<n;i++){
scanf("%s",str[i]);
}
for(int i=1;i<=n;i++){
a[i]=read();
}
for(int i=1;i<=n;i++){
b[i].z=read();
b[i].i=i;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(str[i][j]=='-'){
a[i+1]++;
b[j+1].z++;
}
}
}
int ok=1;
for(int i=1;i<=n;i++){
sort(b+1,b+n+1,cmp);
for(int j=1;j<=a[i];j++){
b[j].z--;
if(b[j].z<0)
ok=0;
cho[i][b[j].i]=1;
}
}
if(ok==0){
cout<<"No";
}
else {
cout<<"Yes\n";
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if((cho[i+1][j+1]==1&&str[i][j]=='+')||(cho[i+1][j+1]==0&&str[i][j]=='-'))
cout<<1;
else cout<<0;
}
cout<<endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5868kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 001 001
result:
ok n=3
Test #2:
score: 0
Accepted
time: 0ms
memory: 5932kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: 0
Accepted
time: 1ms
memory: 5844kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3672kb
input:
1 - -1 1
output:
Yes 1
result:
wrong answer wrong sum at col 1