QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#289761 | #7857. (-1,1)-Sumplete | ucup-team139# | WA | 0ms | 3852kb | C++17 | 1.8kb | 2023-12-23 23:25:13 | 2023-12-23 23:25:13 |
Judging History
answer
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
void solve(int t){
int n;
cin>>n;
vector<string> mat(n);
for(int i=0;i<n;i++){
cin>>mat[i];
}
vector r(n,0),c(n,0);
for(int i=0;i<n;i++)cin>>r[i];
for(int i=0;i<n;i++)cin>>c[i];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(mat[i][j]=='-'){
r[i]++;
c[j]++;
}
}
}
long long totr=0,totc=0;
for(int i=0;i<n;i++){
if(r[i]<0 || c[i]<0){
cout<<"No\n";
return;
}
totr+=r[i];
totc+=c[i];
}
if(totr!=totc){
cout<<"No\n";
}else{
vector ok(n,vector(n,false));
vector<array<int,3>> tmp;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
tmp.push_back({max(r[i],c[j]),i,j});
}
}
sort(tmp.rbegin(),tmp.rend());
for(auto [val,i,j] : tmp){
if(r[i]>0 && c[j]>0){
ok[i][j]=true;
r[i]--;
c[j]--;
}
}
for(int i=0;i<n;i++){
if(r[i]!=0 || c[i]!=0){
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(ok[i][j]^(mat[i][j]=='+')){
cout<<"0";
}else{
cout<<"1";
}
}
cout<<"\n";
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve(i);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 001 001
result:
ok n=3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
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: 3648kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
No
result:
wrong answer Jury has the answer but participant has not