# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1205742 | ofoz | Red-blue table (IZhO19_stones) | Pypy 3 | 392 ms | 59912 KiB |
from collections import deque
from sys import setrecursionlimit
import heapq
def solve():
n, m = map(int, input().split(" "))
grid = [[1] * m for _ in range(n)]
q = []
for i in range(n): heapq.heappush(q, (0, i))
j = 0
cur = 0
while j < m:
cnt, i = heapq.heappop(q)
if cnt >= (m-1)//2: break
grid[i][j] = 0
heapq.heappush(q, (cnt+1, i))
cur += 1
if cur > n//2:
cur = 0
j += 1
if (n & 1): print(n + m - 2)
else: print(n + m - 3)
for row in grid:
print(*row, sep = "")
"""
"""
for _ in range(int(input())): solve()
컴파일 시 표준 출력 (stdout) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |