QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546354#7857. (-1,1)-Sumpletecyc_43346WA 1ms7796kbC++141.4kb2024-09-03 23:33:072024-09-03 23:33:09

Judging History

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

  • [2024-09-03 23:33:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7796kb
  • [2024-09-03 23:33:07]
  • 提交

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";
        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";
                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) 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: 100
Accepted
time: 1ms
memory: 5720kb

input:

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

output:

Yes
111
111
111

result:

ok n=3

Test #2:

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

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

input:

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

output:

No

result:

ok n=3

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5808kb

input:

1
-
-1
1

output:

Yes
1

result:

wrong answer wrong sum at col 1