QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#765241#7857. (-1,1)-SumpleteshaochangWA 1ms5968kbC++201.1kb2024-11-20 13:19:382024-11-20 13:19:40

Judging History

你现在查看的是最新测评结果

  • [2024-11-20 13:19:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5968kb
  • [2024-11-20 13:19:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct p{
    int i,v;
}b[4005];
bool cmp(p &a,p &b){
    return a.v>b.v;
}
char g[4005][4005];
int n,ans[4005][4005],a[4005],f=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>g[i][j];
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)scanf("%d",&b[i].v),b[i].i=i;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(g[i][j]=='-'){
                a[i]++;
                b[j].v++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        sort(b+1,b+n+1,cmp);
        if(a[i]<0){
            f=1;
            break;
        }
        for(int j=1;j<=a[i];j++)ans[i][b[j].i]=1,b[j].v--;
    }
    for(int i=1;i<=n;i++)if(b[i].v<0){
        f=1;
        break;
    }
    if(f){
        printf("No\n");
    }
    else{
        printf("Yes\n");
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(g[i][j]=='-')ans[i][j]=(ans[i][j]==0)?1:0;
                printf("%d",ans[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5968kb

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
111
001
001

result:

ok n=3

Test #2:

score: 0
Accepted
time: 1ms
memory: 5920kb

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: 5900kb

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 5960kb

input:

1
-
-1
1

output:

Yes
1

result:

wrong answer wrong sum at col 1