QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#289204 | #7857. (-1,1)-Sumplete | ucup-team1001# | WA | 0ms | 3868kb | C++20 | 2.9kb | 2023-12-23 16:06:44 | 2023-12-23 16:06:44 |
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;
}
}
}
// 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3568kb
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: 3864kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
No
result:
ok n=3
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1 - -1 1
output:
No
result:
ok n=1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1 - 0 0
output:
Yes 0
result:
ok n=1
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
20 +-------+-----+++-++ -+-++++----++-++-++- -+++--+---+--+-++--- -+++-+--+----++---+- +++-+-++++++-+-+---+ -++-----+----++++++- +-++--+++++-++-+---- +-+----+---+-+++--+- +++++-+++++----+--+- ------++++---+--++-- ++++--------++++--+- -+-+-++++-+-++-++--+ ---+-++---+-++-++--- +-++++-++----+-+++-- +-+...
output:
No
result:
wrong answer Jury has the answer but participant has not