QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546341#7857. (-1,1)-Sumpletecyc_43346WA 1ms5760kbC++141.4kb2024-09-03 23:28:092024-09-03 23:28:09

Judging History

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

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

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]<<" ";
        }
        cout<<endl;
    }
}

int main()
{
    cin.tie(0) -> sync_with_stdio(false);
    solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5760kb

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