QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546344#7857. (-1,1)-Sumpletecyc_43346WA 1ms5728kbC++141.4kb2024-09-03 23:29:372024-09-03 23:29:37

Judging History

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

  • [2024-09-03 23:29:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5728kb
  • [2024-09-03 23:29:37]
  • 提交

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