QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72285 | #2553. Bingo | CSU2023# | AC ✓ | 2ms | 3736kb | C++14 | 2.8kb | 2023-01-15 12:21:52 | 2023-01-15 12:24:05 |
Judging History
answer
#include <bits/stdc++.h>
template <class T>
inline void read(T &res)
{
char ch; bool flag = false; res = 0;
while (ch = getchar(), !isdigit(ch) && ch != '-');
ch == '-' ? flag = true : res = ch ^ 48;
while (ch = getchar(), isdigit(ch))
res = res * 10 + ch - 48;
flag ? res = -res : 0;
}
template <class T>
inline void put(T x)
{
if (x > 9)
put(x / 10);
putchar(x % 10 + 48);
}
template <class T>
inline void _put(T x)
{
if (x < 0)
x = -x, putchar('-');
put(x);
}
template <class T>
inline void CkMin(T &x, T y) {x > y ? x = y : 0;}
template <class T>
inline void CkMax(T &x, T y) {x < y ? x = y : 0;}
template <class T>
inline T Min(T x, T y) {return x < y ? x : y;}
template <class T>
inline T Max(T x, T y) {return x > y ? x : y;}
template <class T>
inline T Abs(T x) {return x < 0 ? -x : x;}
template <class T>
inline T Sqr(T x) {return x * x;}
// 若传入 int x 同时结果可能爆 int 应这样写 Sqr((ll)x)
using std::map;
using std::set;
using std::pair;
using std::bitset;
using std::string;
using std::vector;
using std::complex;
using std::multiset;
using std::priority_queue;
typedef long long ll;
typedef long double ld;
typedef complex<ld> com;
typedef pair<int, int> pir;
const ld pi = acos(-1.0);
const ld eps = 1e-8;
const int N = 105;
const int Maxn = 1e9;
const int Minn = -1e9;
const int mod = 998244353;
int T_data, n, k, a[N][N];
inline void add(int &x, int y)
{
x += y;
x >= mod ? x -= mod : 0;
}
inline void dec(int &x, int y)
{
x -= y;
x < 0 ? x += mod : 0;
}
inline void Print()
{
for (int i = 1; i <= n; ++i, putchar('\n'))
for (int j = 1; j <= n; ++j)
putchar(a[i][j]);
}
inline void Delete(int cnt)
{
if (cnt == 0)
return ;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (a[i][j] == '#')
{
a[i][j] = '.';
if (--cnt == 0)
return ;
}
}
int main()
{
scanf("%d%d", &n, &k);
if (n == 2)
{
if (k <= 1)
{
puts("YES");
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
a[i][j] = '.';
if (k == 1)
a[1][1] = '#';
Print();
}
else
puts("NO");
}
else if (n & 1)
{
if (k <= n * (n - 1))
{puts("YES");
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
a[i][j] = i == j ? '.' : '#';
Delete(n * (n - 1) - k);
Print();
}
else
puts("NO");
}
else
{
if (k <= n * (n - 1))
{puts("YES");
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (i > 1 && i < n)
a[i][j] = i == j ? '.' : '#';
else if (i == 1)
a[i][j] = j == n ? '.' : '#';
else
a[i][j] = j == 1 ? '.' : '#';
Delete(n * (n - 1) - k);
Print();
}
else
puts("NO");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3684kb
input:
4 2
output:
YES .... .... .... ..##
result:
ok n=4, k=2
Test #2:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
4 16
output:
NO
result:
ok n=4, k=16
Test #3:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
2 0
output:
YES .. ..
result:
ok n=2, k=0
Test #4:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
3 0
output:
YES ... ... ...
result:
ok n=3, k=0
Test #5:
score: 0
Accepted
time: 2ms
memory: 3400kb
input:
3 2
output:
YES ... ... ##.
result:
ok n=3, k=2
Test #6:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
5 4
output:
YES ..... ..... ..... ..... ####.
result:
ok n=5, k=4
Test #7:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
25 20
output:
YES ......................... ......................... ......................... ......................... ......................... ......................... ......................... ......................... ......................... ......................... ......................... .............
result:
ok n=25, k=20
Test #8:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
31 29
output:
YES ............................... ............................... ............................... ............................... ............................... ............................... ............................... ............................... ............................... ...........
result:
ok n=31, k=29
Test #9:
score: 0
Accepted
time: 2ms
memory: 3484kb
input:
44 10
output:
YES ............................................ ............................................ ............................................ ............................................ ............................................ ............................................ .............................
result:
ok n=44, k=10
Test #10:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
44 22
output:
YES ............................................ ............................................ ............................................ ............................................ ............................................ ............................................ .............................
result:
ok n=44, k=22
Test #11:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
100 0
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=0
Test #12:
score: 0
Accepted
time: 2ms
memory: 3736kb
input:
100 1
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=1
Test #13:
score: 0
Accepted
time: 0ms
memory: 3368kb
input:
100 2
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=2
Test #14:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
100 50
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=50
Test #15:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
100 98
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=98
Test #16:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
100 99
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=99
Test #17:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
99 97
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=97
Test #18:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
99 98
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=98
Test #19:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1 0
output:
YES .
result:
ok n=1, k=0
Test #20:
score: 0
Accepted
time: 2ms
memory: 3692kb
input:
1 1
output:
NO
result:
ok n=1, k=1
Test #21:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
2 0
output:
YES .. ..
result:
ok n=2, k=0
Test #22:
score: 0
Accepted
time: 1ms
memory: 3404kb
input:
2 1
output:
YES #. ..
result:
ok n=2, k=1
Test #23:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
2 2
output:
NO
result:
ok n=2, k=2
Test #24:
score: 0
Accepted
time: 1ms
memory: 3404kb
input:
2 3
output:
NO
result:
ok n=2, k=3
Test #25:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
2 4
output:
NO
result:
ok n=2, k=4
Test #26:
score: 0
Accepted
time: 0ms
memory: 3400kb
input:
3 0
output:
YES ... ... ...
result:
ok n=3, k=0
Test #27:
score: 0
Accepted
time: 2ms
memory: 3404kb
input:
3 1
output:
YES ... ... .#.
result:
ok n=3, k=1
Test #28:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
3 3
output:
YES ... ..# ##.
result:
ok n=3, k=3
Test #29:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
3 5
output:
YES ..# #.# ##.
result:
ok n=3, k=5
Test #30:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
3 6
output:
YES .## #.# ##.
result:
ok n=3, k=6
Test #31:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
3 7
output:
NO
result:
ok n=3, k=7
Test #32:
score: 0
Accepted
time: 2ms
memory: 3684kb
input:
3 8
output:
NO
result:
ok n=3, k=8
Test #33:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
3 9
output:
NO
result:
ok n=3, k=9
Test #34:
score: 0
Accepted
time: 2ms
memory: 3404kb
input:
4 0
output:
YES .... .... .... ....
result:
ok n=4, k=0
Test #35:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
4 3
output:
YES .... .... .... .###
result:
ok n=4, k=3
Test #36:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
4 4
output:
YES .... .... ...# .###
result:
ok n=4, k=4
Test #37:
score: 0
Accepted
time: 0ms
memory: 3400kb
input:
4 5
output:
YES .... .... .#.# .###
result:
ok n=4, k=5
Test #38:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
4 16
output:
NO
result:
ok n=4, k=16
Test #39:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
4 9
output:
YES .... #.## ##.# .###
result:
ok n=4, k=9
Test #40:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
4 10
output:
YES ..#. #.## ##.# .###
result:
ok n=4, k=10
Test #41:
score: 0
Accepted
time: 2ms
memory: 3336kb
input:
4 12
output:
YES ###. #.## ##.# .###
result:
ok n=4, k=12
Test #42:
score: 0
Accepted
time: 2ms
memory: 3332kb
input:
4 13
output:
NO
result:
ok n=4, k=13
Test #43:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 0
output:
YES .
result:
ok n=1, k=0
Test #44:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
2 1
output:
YES #. ..
result:
ok n=2, k=1
Test #45:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 0
output:
YES .
result:
ok n=1, k=0
Test #46:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
1 1
output:
NO
result:
ok n=1, k=1
Test #47:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
2 0
output:
YES .. ..
result:
ok n=2, k=0
Test #48:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
2 1
output:
YES #. ..
result:
ok n=2, k=1
Test #49:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
2 2
output:
NO
result:
ok n=2, k=2
Test #50:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
2 3
output:
NO
result:
ok n=2, k=3
Test #51:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
2 4
output:
NO
result:
ok n=2, k=4
Test #52:
score: 0
Accepted
time: 2ms
memory: 3400kb
input:
3 3
output:
YES ... ..# ##.
result:
ok n=3, k=3
Test #53:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
3 6
output:
YES .## #.# ##.
result:
ok n=3, k=6
Test #54:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
3 7
output:
NO
result:
ok n=3, k=7
Test #55:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
3 9
output:
NO
result:
ok n=3, k=9
Test #56:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
4 4
output:
YES .... .... ...# .###
result:
ok n=4, k=4
Test #57:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
4 12
output:
YES ###. #.## ##.# .###
result:
ok n=4, k=12
Test #58:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
4 13
output:
NO
result:
ok n=4, k=13
Test #59:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
4 15
output:
NO
result:
ok n=4, k=15
Test #60:
score: 0
Accepted
time: 0ms
memory: 3392kb
input:
5 20
output:
YES .#### #.### ##.## ###.# ####.
result:
ok n=5, k=20
Test #61:
score: 0
Accepted
time: 2ms
memory: 3400kb
input:
5 21
output:
NO
result:
ok n=5, k=21
Test #62:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
12 34
output:
YES ............ ............ ............ ............ ............ ............ ............ ............ ...........# #########.## ##########.# .###########
result:
ok n=12, k=34
Test #63:
score: 0
Accepted
time: 2ms
memory: 3660kb
input:
23 45
output:
YES ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ...........
result:
ok n=23, k=45
Test #64:
score: 0
Accepted
time: 2ms
memory: 3456kb
input:
40 1560
output:
YES #######################################. #.###################################### ##.##################################### ###.#################################### ####.################################### #####.################################## ######.################################# #######.#...
result:
ok n=40, k=1560
Test #65:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
40 1561
output:
NO
result:
ok n=40, k=1561
Test #66:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
40 1599
output:
NO
result:
ok n=40, k=1599
Test #67:
score: 0
Accepted
time: 2ms
memory: 3428kb
input:
99 0
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=0
Test #68:
score: 0
Accepted
time: 2ms
memory: 3684kb
input:
99 98
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=98
Test #69:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
99 101
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=101
Test #70:
score: 0
Accepted
time: 0ms
memory: 3368kb
input:
99 2345
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=2345
Test #71:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
99 4567
output:
YES ................................................................................................... ................................................................................................... ...................................................................................................
result:
ok n=99, k=4567
Test #72:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
99 9797
output:
NO
result:
ok n=99, k=9797
Test #73:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
99 9595
output:
YES ................................................................................................... ..........######################################################################################### ##.#############################################################################################...
result:
ok n=99, k=9595
Test #74:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
99 9701
output:
YES ..################################################################################################# #.################################################################################################# ##.#############################################################################################...
result:
ok n=99, k=9701
Test #75:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
99 9702
output:
YES .################################################################################################## #.################################################################################################# ##.#############################################################################################...
result:
ok n=99, k=9702
Test #76:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
99 9703
output:
NO
result:
ok n=99, k=9703
Test #77:
score: 0
Accepted
time: 1ms
memory: 3548kb
input:
99 9801
output:
NO
result:
ok n=99, k=9801
Test #78:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
100 0
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=0
Test #79:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
100 1
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=1
Test #80:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
100 10
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=10
Test #81:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
100 100
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=100
Test #82:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
100 1000
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=1000
Test #83:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
100 9406
output:
YES .................................................................................................... .................................................................................................... .................................................................................................
result:
ok n=100, k=9406
Test #84:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
100 9876
output:
YES ........................###########################################################################. #.################################################################################################## ##.###########################################################################################...
result:
ok n=100, k=9876
Test #85:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
100 9898
output:
YES ..#################################################################################################. #.################################################################################################## ##.###########################################################################################...
result:
ok n=100, k=9898
Test #86:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
100 9899
output:
YES .##################################################################################################. #.################################################################################################## ##.###########################################################################################...
result:
ok n=100, k=9899
Test #87:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100 9900
output:
YES ###################################################################################################. #.################################################################################################## ##.###########################################################################################...
result:
ok n=100, k=9900
Test #88:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
100 9901
output:
NO
result:
ok n=100, k=9901
Test #89:
score: 0
Accepted
time: 1ms
memory: 3336kb
input:
100 9944
output:
NO
result:
ok n=100, k=9944
Test #90:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
100 9990
output:
NO
result:
ok n=100, k=9990
Test #91:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
100 10000
output:
NO
result:
ok n=100, k=10000
Test #92:
score: 0
Accepted
time: 1ms
memory: 3424kb
input:
65 4160
output:
YES .################################################################ #.############################################################### ##.############################################################## ###.############################################################# ####.###########################...
result:
ok n=65, k=4160
Test #93:
score: 0
Accepted
time: 2ms
memory: 3404kb
input:
65 4161
output:
NO
result:
ok n=65, k=4161
Test #94:
score: 0
Accepted
time: 2ms
memory: 3364kb
input:
77 5852
output:
YES .############################################################################ #.########################################################################### ##.########################################################################## ###.##########################################################...
result:
ok n=77, k=5852
Test #95:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
77 5853
output:
NO
result:
ok n=77, k=5853
Test #96:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
37 1332
output:
YES .#################################### #.################################### ##.################################## ###.################################# ####.################################ #####.############################### ######.############################## #######.######################...
result:
ok n=37, k=1332
Test #97:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
37 1333
output:
NO
result:
ok n=37, k=1333
Test #98:
score: 0
Accepted
time: 2ms
memory: 3684kb
input:
88 7656
output:
YES #######################################################################################. #.###################################################################################### ##.##################################################################################### ###.#########################...
result:
ok n=88, k=7656
Test #99:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
88 7657
output:
NO
result:
ok n=88, k=7657