QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#294673 | #7857. (-1,1)-Sumplete | brakzero | WA | 1ms | 5824kb | C++14 | 1.7kb | 2023-12-30 15:41:54 | 2023-12-30 15:41:54 |
Judging History
answer
#include<bits/stdc++.h>
#define P make_pair
using namespace std;
bool res[4001][4001];
int z[4001],h[4001];
int pos[4001],n,pos2[4001];
vector<int> vec1,vec2,vec3;
bool comp(int x,int y)
{
return z[x]<z[y];
}
bool comp2(int x,int y)
{
return h[x]>h[y];
}
priority_queue<pair<int,int> >pq;
void gb()
{
vec3.clear();
int l=0,r=0;
while(l<vec1.size()&&r<vec2.size())
{
if(h[vec1[l]]>h[vec2[r]])
{
vec3.push_back(vec1[l++]);
}
else vec3.push_back(vec2[r++]);
}
while(l<vec1.size()) vec3.push_back(vec1[l++]);
while(r<vec2.size()) vec3.push_back(vec2[r++]);
swap(vec3,vec1);
}
signed main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
char c;
cin>>c;
if(c=='+') res[i][j]=false;
else res[i][j]=true;
}
}
for(int i=1;i<=n;++i) scanf("%d",&z[i]),pos[i]=i;
for(int i=1;i<=n;++i) scanf("%d",&h[i]),pos2[i]=i;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
if(res[i][j]==true)
{
z[i]++;
h[j]++;
}
}
}
for(int i=1;i<=n;++i) pq.push(P(h[i],i));
sort(pos+1,pos+1+n,comp);
sort(pos2+1,pos2+1+n,comp2);
for(int i=1;i<=n;++i) vec1.push_back(pos2[i]);
for(int i=1;i<=n;++i)
{
if(z[pos[i]]>n||z[pos[i]]<0) {cout<<"No";return 0;}
for(int j=0;j<z[pos[i]];++j)
{
h[vec1[j]]--;
res[pos[i]][vec1[j]]^=1;
vec2.push_back(vec1[j]);
}
vec3.clear();
for(int j=z[pos[i]];j<n;++j) vec3.push_back(vec1[j]);
swap(vec3,vec1);
gb();
}
for(int i=1;i<=n;++i)
{
if(h[i])
{
cout<<"No";
return 0;
}
}
cout<<"Yes\n";
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
if(res[i][j]) cout<<"1";
else cout<<"0";
}
cout<<endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3796kb
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: 5824kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3772kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
No
result:
wrong answer Jury has the answer but participant has not