QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#299284 | #7857. (-1,1)-Sumplete | ucup-team134# | WA | 1ms | 8128kb | C++14 | 2.7kb | 2024-01-06 18:27:01 | 2024-01-06 18:27:01 |
Judging History
answer
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
using u128=__uint128_t;
typedef pair<int,int> pii;
const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}
const int maxn=4000+10;
int n,a[maxn][maxn];
pii r[maxn];
int c[maxn],rez[maxn][maxn];
int main(){
///freopen("test.txt","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;i++){
string s;
cin>>s;
for(int j=0;j<n;j++){
a[i][j+1]=(s[j]=='+')?1:-1;
}
}
for(int i=1;i<=n;i++){
scanf("%d",&r[i].ff);
r[i].ss=i;
}
for(int i=1;i<=n;i++){
scanf("%d",&c[i]);
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]==1){
rez[i][j]=1;
}
else{
r[i].ff++;
c[j]++;
}
}
}
sort(r+1,r+n+1);
int e=1;
int sum=0;
for(int i=1;i<=n;i++){
if(r[i].ff<0 || c[i]<0){
e=0;
break;
}
sum+=r[i].ff-c[i];
}
if(!e || sum!=0){
printf("No\n");
return 0;
}
for(int i=1;i<=n;i++){
vector<pii>pom;
for(int j=1;j<=c[i];j++){
pom.pb(r[n-j+1]);
if(r[n-j+1].ff==0){
e=0;
break;
}
}
if(!e)break;
for(int j=0;j<pom.size();j++){
rez[pom[j].ss][i]^=1;
pom[j].ff--;
}
vector<pii>pom2;
int pt1=1;
int pt2=0;
for(int j=1;j<=n;j++){
pii v1,v2;
v1={1e9,-1};
v2={1e9,-1};
if(pt1<=n-c[i])v1=r[pt1];
if(pt2<pom.size())v2=pom[pt2];
if(v1<v2){
pom2.pb(v1);
pt1++;
}
else{
pom2.pb(v2);
pt2++;
}
}
for(int j=0;j<pom2.size();j++)r[j+1]=pom2[j];
}
if(!e){
printf("No\n");
return 0;
}
printf("Yes\n");
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
printf("%d",(rez[i][j]^1));
}
printf("\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5832kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 001 001 111
result:
ok n=3
Test #2:
score: 0
Accepted
time: 1ms
memory: 5824kb
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: 5832kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 1ms
memory: 5972kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 1ms
memory: 5800kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 8128kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
No
result:
wrong answer Jury has the answer but participant has not