t = int(input())
while t:
n, m = map(int, input().split())
# (n,m) <-> (m,n)
# by "n>=m" we will solve (n,m) and (m,n)
swapped = False
if n<m:
n, m = m, n
swapped = True
a = []
for y in range(n):
a.append([])
for x in range(m):
a[y].append('+')
answer = n
'''
0-++
1-++
2+-+
012
(m-1)//2
x
n//2+1
o'zgartirishlar chegarasi
1 3
+n
+
+
m
'''
x = 0; c = 0
for _ in range((m-1)//2):
for y in range(n):
a[y][x] = '-'
c += 1
if c >= n//2+1:
answer += 1
x += 1
c = 0
print(answer)
if not swapped:
for y in range(n):
for x in range(m):
print(a[y][x], end='')
print()
else:
# n -> m, m -> n
for x in range(m):
for y in range(n):
if a[y][x] == '+':
print('-', end='')
else:
print('+', end='')
print()
t -= 1
# o'zgatirish chegarasi - (m-1)//2
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
2832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2860 KB |
Output is correct |
3 |
Correct |
33 ms |
2832 KB |
Output is correct |
4 |
Correct |
55 ms |
2884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
867 ms |
4164 KB |
Output is correct |
2 |
Correct |
796 ms |
9052 KB |
Output is correct |
3 |
Correct |
787 ms |
10736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
832 ms |
4244 KB |
Output is correct |
2 |
Correct |
698 ms |
7984 KB |
Output is correct |
3 |
Correct |
673 ms |
6396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2860 KB |
Output is correct |
3 |
Correct |
33 ms |
2832 KB |
Output is correct |
4 |
Correct |
55 ms |
2884 KB |
Output is correct |
5 |
Correct |
867 ms |
4164 KB |
Output is correct |
6 |
Correct |
796 ms |
9052 KB |
Output is correct |
7 |
Correct |
787 ms |
10736 KB |
Output is correct |
8 |
Correct |
832 ms |
4244 KB |
Output is correct |
9 |
Correct |
698 ms |
7984 KB |
Output is correct |
10 |
Correct |
673 ms |
6396 KB |
Output is correct |
11 |
Correct |
207 ms |
3140 KB |
Output is correct |
12 |
Correct |
668 ms |
7840 KB |
Output is correct |
13 |
Correct |
708 ms |
6204 KB |
Output is correct |
14 |
Correct |
530 ms |
5008 KB |
Output is correct |
15 |
Correct |
874 ms |
12720 KB |
Output is correct |
16 |
Correct |
629 ms |
10020 KB |
Output is correct |
17 |
Correct |
305 ms |
6124 KB |
Output is correct |