QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749785 | #7857. (-1,1)-Sumplete | caiwen | WA | 1ms | 5500kb | C++14 | 1.4kb | 2024-11-15 10:13:45 | 2024-11-15 10:13:46 |
Judging History
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