QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#749785#7857. (-1,1)-SumpletecaiwenWA 1ms5500kbC++141.4kb2024-11-15 10:13:452024-11-15 10:13:46

Judging History

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

  • [2024-11-15 10:13:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5500kb
  • [2024-11-15 10:13:45]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ls(k) (k)<<1
#define rs(k) (k)<<1|1
#define debug(x) cout<<#x<<"="<<x<<endl
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=0;
typedef pair<int,int> pii;
#define _ 4003
int r[_],c[_],nr[_],nb[_][_];
pii nc[_];
inline void subtask(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string str;cin>>str;
        for(int j=1;j<=n;j++){
            if(str[j-1]=='-') nb[i][j]=1,nr[i]--,nc[j].second--;
        }
    }
    for(int i=1;i<=n;i++) cin>>r[i],nr[i]=r[i]-nr[i];
    for(int i=1;i<=n;i++) cin>>c[i],nc[i].second=c[i]-nc[i].second,nc[i].first=i;
    bool flag=true;
    for(int i=1;i<=n;i++){
        sort(nc+1,nc+n+1,[](pii x,pii y){return x.second>y.second;});
        int p=1;
        while(p<=n&&nr[i]){
            if(!nc[p].second) p++;
            else{
                nr[i]--;
                nc[p].second--;
                nb[i][nc[p].first]=1-nb[i][nc[p].first];
                p++;
            }
        } 
        if(nr[i]){
            flag=false;
            break;
        }
        //debug(a2);
    }
    if(!flag) cout<<"NO";
    else{
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++) cout<<nb[i][j];
            if(i!=n) cout<<endl;
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    int t=1;//cin>>t;
    while(t--) subtask();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

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

input:

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

output:

YES
110
100
000

result:

ok n=3

Test #3:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

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

output:

NO

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

YES
1

result:

wrong answer wrong sum at col 1