QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#294679 | #7857. (-1,1)-Sumplete | brakzero | AC ✓ | 958ms | 19548kb | C++14 | 1.6kb | 2023-12-30 15:44:49 | 2023-12-30 15:44:49 |
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];
}
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]++;
}
}
}
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;}
vec2.clear();
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;
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
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: 3648kb
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: 3628kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
Yes 11011100000101101001 11111101001100011110 01001001000001100010 10000111011001110111 01001010110111111001 11000011111001010011 01000000000111000101 00111001010111100101 00001100100000000111 10011110000101011010 00000111111111000111 10110100110011111110 00001110011011001110 11111001010100011001 01...
result:
ok n=20
Test #7:
score: 0
Accepted
time: 1ms
memory: 5856kb
input:
100 ++++-+-+--++++++-+--+--++-+-+--+++++-+++---+-+-+-++-+-+++-------+-++--+-++--+--+++++-++-+---+--+--++ -++--++-+-++++-+---++-+-+-+-+-+-+-+-+--+-+--+--+++---+--+-----+-----+-++-++-+-++++++--+-+++-+++-++++ --+---++-++--++-+++-------+--+-++------+-----+--+----++++++++-+--+++++--++--+-+-+++---+--+++-+...
output:
Yes 1111010101111110110010011010100011010110010000011111001110000001101001101100100011011101000100010011 0110011010111101010111111010101000101011010000001100000010100110100010110010001101110010101011111111 0000100101100100111000000010000110000011001011001000011011001010010101000100100000100010001100...
result:
ok n=100
Test #8:
score: 0
Accepted
time: 16ms
memory: 6564kb
input:
500 --+-+-+-++-----+++--+-+++-+---+-+-------+++--++++++-+--++--+-+-++++-++++--++--+---++--++----++--+---++-++--+-----+-+---++-++++-+++++++---++-++--+-++++-+----++-+++-+++---+--+++-+--++-++--+++++++-+++--+---+---+-+---++-+-+--+-+++-++-----+++-++-+++-+-++--++++++-+-++-+++---++-+++-++----+--+++----++++...
output:
Yes 11000101001111100111111101011101011010010101000000010110111010110000100011000000111011001111001001111010001001111110111001001011000000111001001001000010110011101000001101010010011001010000001001000100011011101111100100011110011101110100010010000110011000000010001100000000000000110101000010110001...
result:
ok n=500
Test #9:
score: 0
Accepted
time: 948ms
memory: 19448kb
input:
4000 -++-+-+-+--+-++++---+-++------++---+-+++--+++--+++++++---+-++-+++++++----+---+++-++--++---+-++--+----+---+--++-+-+-+-----+-+---++-++--+---+++-++++-+-----++--++-++---++-+--+++-+--+--+-+-++-+++--++---+++-+-+---+++-++-+-++-+-+++---+++---+-+--++---+-+---+--+++--+----+-+--++---+-----+-+--+----+-+++-...
output:
Yes 01011000101110011001001100000011010000110000111011011111101000011111100010101001000011011001000001001111010101011111001000111101011101011100011101011010111101011011000001100010110110000000011001011001011101000011000110111010010010010010110100011010100000010010100111001110000000100111001101110111...
result:
ok n=4000
Test #10:
score: 0
Accepted
time: 918ms
memory: 19468kb
input:
4000 +---+--++-+--++-+-++--+++--++--+++-+-+-+--++++++-++-+-+++-+---++++-+-+++----++-+---++--++--+++-----++---++-+--++++----++--++--+-+-++--+--+++++-+---+++-+++--++++-++-+++++++----+++-----+--++-+++-++-++-+++-+--++++++-+--++--+-+---++--------+-+--++----+-++-+-++---+--++--+-+--+-+++-+--+--++++-++----+...
output:
Yes 11100111111000110100000100101110000011110101010011111100010111110110101010010011001010110110001110101010001010010001111110111001000011101000001100101010001010110101001101011010100101001101110100000111001001000010100100110101110001001100110110001110101111011010101011010100000000110010111100011001...
result:
ok n=4000
Test #11:
score: 0
Accepted
time: 958ms
memory: 19304kb
input:
4000 -+--+------+--+++-++-----++--+-++-++-++-+-+-++++++--++--+-++-+-+++---++-+-+++++-++++++-+-++-++-++-+-++---+-+-------++-+++-++-+-++++-++-+-+-----+----+--+----++++-------++-+--+++----+++++++-+--+-+---+-+++++-+-----++-------++++--+-+-++---++++-++++-++-+++-+-++---+--+---+-++++++--++---+-++++++-+-+--...
output:
Yes 01011011000100100001111001100101001100101111001101010100001101110110111011001101101111010110011110101010000000000001101110100100101110111100111110101001110011111010011110001111001011011010101111100000101101001111001000101110100110111011001111000010111011001000111100111011100101000101111110101101...
result:
ok n=4000
Test #12:
score: 0
Accepted
time: 892ms
memory: 19464kb
input:
4000 +-+-----++++-----++++-+-++-+----+++---++--+---+++-+-++------+-+-++++----+-++++--+-++----+-+---+--+-----+-++--++-+++---+---+++---++-+++---++++---++----+++--+---+---+++-++-+-+-+--+++--++----++-+------+++-++-++--+--+++---+-------++++-+-++--++-+--+------+++++---+---++-++++-+++-++++-+---++-++++----+...
output:
Yes 00111100000000011110001101000101000011100101100010001101110100111001011111100001010111101100000100111110101111010011111011111011000001100011010100101100000111001110011001100101101001111000001011110101000001000010000101111001100000011011100101001110111000111001111110010101011001110110000110101000...
result:
ok n=4000
Test #13:
score: 0
Accepted
time: 918ms
memory: 19532kb
input:
4000 -+++---+-------+-++++-+++-++-+--++----++++++---+---++-++++-+++-++++-+---+--+++-----+-+--++-+--+-++++--+--++-+---+++++++++-+++++++-+++--+-+---++-+-++----+-++--++-++++++++++++++-+++-++-+++-++-++---+---+++-+-+++++++--+-+++-++-+-----+++-++--+++------+++--+++---+--+----++-+--+-+---+--+---+-+-+--++++...
output:
Yes 11100000101110100110010000111101110000110100110100100100000010110110000001001000000001010011000001001100000000111101011110111010101011001001111110101011100010111101010111010010110111001000000100111110111101101110001000011101010101010111011110010101000111000110110110101001110000011001100011111010...
result:
ok n=4000
Test #14:
score: 0
Accepted
time: 902ms
memory: 19388kb
input:
4000 +--+++++--++--+-+++-++-+-+-+-+--++------++++---+++-+-+--+------++-+--++-+-+++-----+-+++++-+------++++-++++-+--+------++--+++++-+-+--+-+++++++++++++++-+--+-+-+---+-+-+++++-++--+-+---++-++--+--+-+++-+-+++++-+--++-+----+++-++-++++-+---+--+-++-++-+-+-+---++-++-+-+----++-++++-----------+++--++++-++-...
output:
Yes 01100000110011010001001010101111101101110000111000101011011111100101100101000101110100001101101110000100001011001111100110000010101101000000000000000101001010111010101000100110101110010111011010001010000010110110111100010011011101110110100100101010111001001010101000100101011111111100001000000010...
result:
ok n=4000
Test #15:
score: 0
Accepted
time: 941ms
memory: 19548kb
input:
4000 ---++-++-+-+----++-++++-----------+++--++++-++-++--+-+--+--+-+-++++--++-++--+++++--++--+-+----+-+---++-+++-+--+-++++++++-++---++++-+--+-+++---+-+--+--+-+--+--++++++-+---++++++-++++----+-+-+-++--+---+--+-+++--++++++-+++-+---+--+-----------++-+++--+++++++--++-+++++--+++-+-+++++++++--+---+++--+-+-...
output:
Yes 00011011110100001101111000001000001110011110110110000100100101011111011010001101100110010100001011000111110100101111111101100000110001001110001110010010000100110111010001111110101000001000101101100011010111001101110111010001001000000000001101110111111111011010111001110101011011110010001100010000...
result:
ok n=4000
Test #16:
score: 0
Accepted
time: 929ms
memory: 19488kb
input:
4000 ++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...
output:
Yes 10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...
result:
ok n=4000
Test #17:
score: 0
Accepted
time: 920ms
memory: 19388kb
input:
3999 -+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...
output:
Yes 10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...
result:
ok n=3999
Test #18:
score: 0
Accepted
time: 934ms
memory: 19388kb
input:
3998 --------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...
output:
Yes 11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...
result:
ok n=3998
Test #19:
score: 0
Accepted
time: 575ms
memory: 19504kb
input:
4000 ++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...
output:
No
result:
ok n=4000
Test #20:
score: 0
Accepted
time: 565ms
memory: 19548kb
input:
3999 -+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...
output:
No
result:
ok n=3999
Test #21:
score: 0
Accepted
time: 561ms
memory: 19496kb
input:
3998 --------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...
output:
No
result:
ok n=3998
Test #22:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
2 +- -- 0 -1 -1 2
output:
No
result:
ok n=2
Test #23:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
20 --+--------+---++-++ --+++-+----+--++-+++ -+-+-++++---+-+---++ +++-++--++-++-++--++ +---+----+-+++-++++- ----+++++--++----+-+ +-++++----++--++---- ++++++-+-+-++-++--+- -+--+-++++-+-+-+-+-+ --++-+-+--++-++--++- +---+++-+++-+-+-++-+ +++-+--+++-++-+++-+- --++--+-++-+--+-+-++ ----++-+--+-+-++++-+ --+...
output:
No
result:
ok n=20
Test #24:
score: 0
Accepted
time: 517ms
memory: 19516kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
No
result:
ok n=4000
Test #25:
score: 0
Accepted
time: 902ms
memory: 19356kb
input:
3999 -++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...
output:
Yes 10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...
result:
ok n=3999
Test #26:
score: 0
Accepted
time: 896ms
memory: 19312kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
Yes 00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...
result:
ok n=4000
Test #27:
score: 0
Accepted
time: 946ms
memory: 19528kb
input:
3999 -++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...
output:
Yes 01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...
result:
ok n=3999
Test #28:
score: 0
Accepted
time: 936ms
memory: 19312kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
Yes 11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...
result:
ok n=4000
Extra Test:
score: 0
Extra Test Passed