Submission #62054151


Source Code Expand

Copy
def main():
H, W = map(int, input().split())
S = [input() for _ in range(H)]
min_row, max_row = H, -1
min_col, max_col = W, -1
for i in range(H):
for j in range(W):
if S[i][j] == '#':
if i < min_row:
min_row = i
if i > max_row:
max_row = i
if j < min_col:
min_col = j
if j > max_col:
max_col = j
for i in range(min_row, max_row + 1):
for j in range(min_col, max_col + 1):
if S[i][j] == '.':
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    min_row, max_row = H, -1
    min_col, max_col = W, -1
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                if i < min_row:
                    min_row = i
                if i > max_row:
                    max_row = i
                if j < min_col:
                    min_col = j
                if j > max_col:
                    max_col = j

    for i in range(min_row, max_row + 1):
        for j in range(min_col, max_col + 1):
            if S[i][j] == '.':
                exit(print("No"))

    for i in range(H):
        for j in range(W):
            if not (min_row <= i <= max_row and min_col <= j <= max_col):
                if S[i][j] == '#':
                    exit(print("No"))

    print('Yes')

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task C - Paint to make a rectangle
User keysersoze21
Language Python (PyPy 3.10-v7.3.12)
Score 300
Code Size 923 Byte
Status AC
Exec Time 100 ms
Memory 83820 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 41
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 63 ms 76436 KB
example_01.txt AC 60 ms 76496 KB
example_02.txt AC 63 ms 76308 KB
hand_00.txt AC 84 ms 81632 KB
hand_01.txt AC 88 ms 83584 KB
hand_02.txt AC 75 ms 81588 KB
hand_03.txt AC 81 ms 81472 KB
hand_04.txt AC 76 ms 81612 KB
hand_05.txt AC 62 ms 76604 KB
hand_06.txt AC 60 ms 76596 KB
hand_07.txt AC 62 ms 76668 KB
hand_08.txt AC 68 ms 80264 KB
hand_09.txt AC 77 ms 81444 KB
hand_10.txt AC 75 ms 81248 KB
hand_11.txt AC 79 ms 81212 KB
hand_12.txt AC 80 ms 81236 KB
random_00.txt AC 81 ms 81264 KB
random_01.txt AC 99 ms 83392 KB
random_02.txt AC 89 ms 83384 KB
random_03.txt AC 87 ms 81268 KB
random_04.txt AC 90 ms 81616 KB
random_05.txt AC 86 ms 83568 KB
random_06.txt AC 78 ms 81768 KB
random_07.txt AC 87 ms 81756 KB
random_08.txt AC 86 ms 83664 KB
random_09.txt AC 83 ms 81600 KB
random_10.txt AC 95 ms 83640 KB
random_11.txt AC 87 ms 83608 KB
random_12.txt AC 91 ms 83820 KB
random_13.txt AC 86 ms 81796 KB
random_14.txt AC 90 ms 83480 KB
random_15.txt AC 93 ms 83712 KB
random_16.txt AC 95 ms 83636 KB
random_17.txt AC 80 ms 81852 KB
random_18.txt AC 72 ms 81316 KB
random_19.txt AC 94 ms 83660 KB
random_20.txt AC 76 ms 81564 KB
random_21.txt AC 87 ms 83248 KB
random_22.txt AC 100 ms 83668 KB
random_23.txt AC 87 ms 83356 KB
random_24.txt AC 79 ms 81636 KB


2025-04-18 (Fri)
07:07:59 +00:00