QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#289226 | #7857. (-1,1)-Sumplete | ucup-team1001# | AC ✓ | 502ms | 96216kb | C++20 | 3.0kb | 2023-12-23 16:17:12 | 2023-12-23 16:17:13 |
Judging History
answer
/*
Author: haze
2023/12/23
15:19
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int (i) = (l); (i) <= (r); ++(i))
#define drep(i, r, l) for(int (i) = (r); (i) >= (l); --(i))
#define ll long long
#define LL __int128
using namespace std;
inline ll read() {
char ch = getchar();
ll s = 0;
bool w = 0;
while (!isdigit(ch)) {
if (ch == '-')w = 1;
ch = getchar();
}
while (isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
return w ? -s : s;
}
inline char rc() {
char ch = getchar();
while (1) {
if (ch >= '!' && ch <= '~')return ch;
ch = getchar();
}
}
template<class T1, class T2>
T1 min(T1 AA, T2 BB) { return AA > BB ? BB : AA; }
template<class T1, class T2>
T1 max(T1 AA, T2 BB) { return AA < BB ? BB : AA; }
const int itinf = 1e9;
const ll llinf = 4e18;
const int mod = 1000000007;
const int N = 500009;
int main() {
int n = read();
vector<string>s(n);
irep(i, 0, n - 1)
cin >> s[i];
vector<int>li(n), cl(n);
irep(i, 0, n - 1)li[i] = read();
irep(j, 0, n - 1)cl[j] = read();
irep(i, 0, n - 1){
irep(j, 0, n - 1){
if(s[i][j] == '-'){
li[i] ++, cl[j] ++;
}
}
}
if(
accumulate(li.begin(), li.end(), 0) != accumulate(cl.begin(), cl.end(), 0)||
*min_element(li.begin(), li.end()) < 0 ||
*min_element(cl.begin(), cl.end()) < 0 ||
*max_element(li.begin(), li.end()) > n ||
*max_element(cl.begin(), cl.end()) > n
){
puts("No");
return 0;
}
// irep(i, 0, n - 1){
// cerr << li[i] << ' ';
// }
// cerr << endl;
// irep(i, 0, n - 1){
// cerr << cl[i] << ' ';
// }
vector<vector<int>>ans(n, vector<int>(n));
vector<int>linord(n), clorder(n);
irep(i, 0, n - 1)linord[i] = clorder[i] = i;
sort(linord.begin(), linord.end(), [&](int x, int y){
return li[x] > li[y];
});
sort(clorder.begin(), clorder.end(), [&](int x,int y){
return cl[x] > cl[y];
});
for(int x : linord){
int cnt = li[x];
for(int y : clorder){
if(cnt == 0)break;
if(cl[y]){
-- cnt, -- cl[y];
ans[x][y] = 1;
}
}
sort(clorder.begin(), clorder.end(), [&](int x,int y){
return cl[x] > cl[y];
});
}
// irep(i, 0, n - 1){
// cerr << li[i] << ' ';
// }
// cerr << endl;
// irep(i, 0, n - 1){
// cerr << cl[i] << ' ';
// }
if(*max_element(cl.begin(), cl.end())){
puts("No");
return 0;
}
puts("Yes");
irep(i, 0, n - 1){
irep(j, 0, n - 1){
if(ans[i][j] ^ (s[i][j] == '-'))putchar('1');
else putchar('0');
}
putchar('\n');
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
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: 3484kb
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: 3716kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
Yes 01100111111100111011 10011101011110110011 11110111100101100001 10101110010000110101 01101000100101010100 00011010110010111000 00010110000101101100 11010010100101100111 01011010000110101011 00000110001111110101 10001111000100000101 10101101100000011111 11110111011011011100 01101100010001001000 01...
result:
ok n=20
Test #7:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
100 ++++-+-+--++++++-+--+--++-+-+--+++++-+++---+-+-+-++-+-+++-------+-++--+-++--+--+++++-++-+---+--+--++ -++--++-+-++++-+---++-+-+-+-+-+-+-+-+--+-+--+--+++---+--+-----+-----+-++-++-+-++++++--+-+++-+++-++++ --+---++-++--++-+++-------+--+-++------+-----+--+----++++++++-+--+++++--++--+-+-+++---+--+++-+...
output:
Yes 0011111101011111111010001000001101110111000101010100101110000100101110111100100111110111101000011000 0110011010111100000110010111111010111001011010011100010000000110000110110110101111100110110011101110 0000001101000110111000100010010110000000100011000111000111111010001011001101001011110010001011...
result:
ok n=100
Test #8:
score: 0
Accepted
time: 8ms
memory: 5212kb
input:
500 --+-+-+-++-----+++--+-+++-+---+-+-------+++--++++++-+--++--+-+-++++-++++--++--+---++--++----++--+---++-++--+-----+-+---++-++++-+++++++---++-++--+-++++-+----++-+++-+++---+--+++-+--++-++--+++++++-+++--+---+---+-+---++-+-+--+-+++-++-----+++-++-+++-+-++--++++++-+-++-+++---++-+++-++----+--+++----++++...
output:
Yes 10010101001100100011000001111101011101100001100000111101011010101001000010001111111011011111000100110111011011101010111001000010000000011001001101001010111110100111011000110001111001010000000101000110100011101011100100011010010001111110011010001111011100010111011000011001000110111101101110100010...
result:
ok n=500
Test #9:
score: 0
Accepted
time: 461ms
memory: 96216kb
input:
4000 -++-+-+-+--+-++++---+-++------++---+-+++--+++--+++++++---+-++-+++++++----+---+++-++--++---+-++--+----+---+--++-+-+-+-----+-+---++-++--+---+++-++++-+-----++--++-++---++-+--+++-+--+--+-+-++-+++--++---+++-+-+---+++-++-+-++-+-+++---+++---+-+--++---+-+---+--+++--+----+-+--++---+-----+-+--+----+-+++-...
output:
Yes 01001110100110000000100100000000001110100100010111111110010001010011000111110100100001010011111000011100011111000010101001000011111100110101011001001110010010111011110000011001100101000111000111100111001011010000011001111101011111100001001001010101000111111010110101101000100110111110010100101111...
result:
ok n=4000
Test #10:
score: 0
Accepted
time: 483ms
memory: 96056kb
input:
4000 +---+--++-+--++-+-++--+++--++--+++-+-+-+--++++++-++-+-+++-+---++++-+-+++----++-+---++--++--+++-----++---++-+--++++----++--++--+-+-++--+--+++++-+---+++-+++--++++-++-+++++++----+++-----+--++-+++-++-++-+++-+--++++++-+--++--+-+---++--------+-+--++----+-++-+-++---+--++--+-+--+-+++-+--+--++++-++----+...
output:
Yes 01011110001100100100011110000101001010100110110010101001111010011100010001001000011100101010011111110101001111010011101011100000110010001010111110101111001110010011001000011000011111101110110111011110101000101110111011111100001001101111110110010011100101111000010011100010100110110111110111101101...
result:
ok n=4000
Test #11:
score: 0
Accepted
time: 487ms
memory: 96012kb
input:
4000 -+--+------+--+++-++-----++--+-++-++-++-+-+-++++++--++--+-++-+-+++---++-+-+++++-++++++-+-++-++-++-+-++---+-+-------++-+++-++-+-++++-++-+-+-----+----+--+----++++-------++-+--+++----+++++++-+--+-+---+-+++++-+-----++-------++++--+-+-++---++++-++++-++-+++-+-++---+--+---+-++++++--++---+-++++++-+-+--...
output:
Yes 01001010000010010001000001110111100101100110110111001101011111001000111011000100101001011011011010111100011101100111111010101111111001010010000100111010101000000001011111100011000010111110100111110110100111010011011101001110011001110110111010110010101110110001101011100010001100000010010110011000...
result:
ok n=4000
Test #12:
score: 0
Accepted
time: 492ms
memory: 96008kb
input:
4000 +-+-----++++-----++++-+-++-+----+++---++--+---+++-+-++------+-+-++++----+-++++--+-++----+-+---+--+-----+-++--++-+++---+---+++---++-+++---++++---++----+++--+---+---+++-++-+-+-+--+++--++----++-+------+++-++-++--+--+++---+-------++++-+-++--++-+--+------+++++---+---++-++++-+++-++++-+---++-++++----+...
output:
Yes 11111101101000101100101100111111100011111110100010110001110101001000011101101010000001111100000110001101101000100101010110000000000100011000111100111110011010000100000110110001100000001011001011111110010101111111001111110101001001010011110101101010001010111000100000000001010000101011110111101100...
result:
ok n=4000
Test #13:
score: 0
Accepted
time: 482ms
memory: 96216kb
input:
4000 -+++---+-------+-++++-+++-++-+--++----++++++---+---++-++++-+++-++++-+---+--+++-----+-+--++-+--+-++++--+--++-+---+++++++++-+++++++-+++--+-+---++-+-++----+-++--++-++++++++++++++-+++-++-+++-++-++---+---+++-+-+++++++--+-+++-++-+-----+++-++--+++------+++--+++---+--+----++-+--+-+---+--+---+-+-+--++++...
output:
Yes 10100011011011001010001111100100011000011111101000011010100001110101000001101000100100111101100000010000110011001111111101011101101000010000000010010010100111110110110101001101100000011111011110101100110110001101000110101101100001001110110000110111001111010110001111011110011010011000110110010010...
result:
ok n=4000
Test #14:
score: 0
Accepted
time: 469ms
memory: 96008kb
input:
4000 +--+++++--++--+-+++-++-+-+-+-+--++------++++---+++-+-+--+------++-+--++-+-+++-----+-+++++-+------++++-++++-+--+------++--+++++-+-+--+-+++++++++++++++-+--+-+-+---+-+-+++++-++--+-+---++-++--+--+-+++-+-+++++-+--++-+----+++-++-++++-+---+--+-++-++-+-+-+---++-++-+-+----++-++++-----------+++--++++-++-...
output:
Yes 11100000110011011000001010101011001111110000111000101011011111110101100101000110110100000101111110000100000011011111100110100010101101100000010000000101100000111010100110101110101110010001011010001010000010110010111100010010000101110110100100101010111001001010111100100101111110111101011000010010...
result:
ok n=4000
Test #15:
score: 0
Accepted
time: 493ms
memory: 96124kb
input:
4000 ---++-++-+-+----++-++++-----------+++--++++-++-++--+-+--+--+-+-++++--++-++--+++++--++--+-+----+-+---++-+++-+--+-++++++++-++---++++-+--+-+++---+-+--+--+-+--+--++++++-+---++++++-++++----+-+-+-++--+---+--+-+++--++++++-+++-+---+--+-----------++-+++--+++++++--++-+++++--+++-+-+++++++++--+---+++--+-+-...
output:
Yes 01011011010100101101111110000000001110011110110110010100100101111110011011011111100110011100000010001111110100100111111111100011110100101110001010011010100100011111010011111110111100011010101100100010010111101111111001010001011000000000101101010011010110011011110101110101011101110110011110010100...
result:
ok n=4000
Test #16:
score: 0
Accepted
time: 477ms
memory: 96052kb
input:
4000 ++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...
output:
Yes 10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...
result:
ok n=4000
Test #17:
score: 0
Accepted
time: 467ms
memory: 96116kb
input:
3999 -+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...
output:
Yes 10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...
result:
ok n=3999
Test #18:
score: 0
Accepted
time: 502ms
memory: 96120kb
input:
3998 --------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...
output:
Yes 11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...
result:
ok n=3998
Test #19:
score: 0
Accepted
time: 347ms
memory: 96168kb
input:
4000 ++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...
output:
No
result:
ok n=4000
Test #20:
score: 0
Accepted
time: 348ms
memory: 96084kb
input:
3999 -+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...
output:
No
result:
ok n=3999
Test #21:
score: 0
Accepted
time: 356ms
memory: 96100kb
input:
3998 --------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...
output:
No
result:
ok n=3998
Test #22:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 +- -- 0 -1 -1 2
output:
No
result:
ok n=2
Test #23:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
20 --+--------+---++-++ --+++-+----+--++-+++ -+-+-++++---+-+---++ +++-++--++-++-++--++ +---+----+-+++-++++- ----+++++--++----+-+ +-++++----++--++---- ++++++-+-+-++-++--+- -+--+-++++-+-+-+-+-+ --++-+-+--++-++--++- +---+++-+++-+-+-++-+ +++-+--+++-++-+++-+- --++--+-++-+--+-+-++ ----++-+--+-+-++++-+ --+...
output:
No
result:
ok n=20
Test #24:
score: 0
Accepted
time: 211ms
memory: 33488kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
No
result:
ok n=4000
Test #25:
score: 0
Accepted
time: 447ms
memory: 96128kb
input:
3999 -++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...
output:
Yes 10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...
result:
ok n=3999
Test #26:
score: 0
Accepted
time: 446ms
memory: 96176kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
Yes 00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...
result:
ok n=4000
Test #27:
score: 0
Accepted
time: 475ms
memory: 96012kb
input:
3999 -++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...
output:
Yes 01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...
result:
ok n=3999
Test #28:
score: 0
Accepted
time: 499ms
memory: 96008kb
input:
4000 ++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...
output:
Yes 11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...
result:
ok n=4000
Extra Test:
score: 0
Extra Test Passed