Submission #63552477
Source Code Expand
H, W = map(int, input().split())
grid = []
for _ in range(H):
row = list(map(int, list(input())))
grid.append(row)
ans = float("inf")
for pattern in range(1 << W):
current_sum = 0
for i in range(H):
ones_count = 0
for j in range(W):
col_flipped = (pattern >> j) & 1
if (grid[i][j] == 1 and col_flipped == 0) or (
grid[i][j] == 0 and col_flipped == 1
):
ones_count += 1
current_sum += min(ones_count, W - ones_count)
ans = min(ans, current_sum)
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | G - Flip Row or Col |
| User | mu16 |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 594 Byte |
| Status | TLE |
| Exec Time | 2215 ms |
| Memory | 148240 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 600 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 60 ms | 76572 KiB |
| 00_sample_01.txt | AC | 59 ms | 76184 KiB |
| 00_sample_02.txt | AC | 63 ms | 81496 KiB |
| 01_test_00.txt | AC | 81 ms | 81932 KiB |
| 01_test_01.txt | AC | 88 ms | 82344 KiB |
| 01_test_02.txt | AC | 70 ms | 81424 KiB |
| 01_test_03.txt | TLE | 2212 ms | 96992 KiB |
| 01_test_04.txt | AC | 214 ms | 101300 KiB |
| 01_test_05.txt | TLE | 2212 ms | 104816 KiB |
| 01_test_06.txt | TLE | 2214 ms | 137572 KiB |
| 01_test_07.txt | TLE | 2214 ms | 139820 KiB |
| 01_test_08.txt | TLE | 2214 ms | 139636 KiB |
| 01_test_09.txt | TLE | 2214 ms | 148240 KiB |
| 01_test_10.txt | TLE | 2214 ms | 148160 KiB |
| 01_test_11.txt | TLE | 2214 ms | 148036 KiB |
| 01_test_12.txt | TLE | 2214 ms | 148040 KiB |
| 01_test_13.txt | TLE | 2214 ms | 147740 KiB |
| 01_test_14.txt | TLE | 2214 ms | 147796 KiB |
| 01_test_15.txt | TLE | 2214 ms | 139124 KiB |
| 01_test_16.txt | TLE | 2212 ms | 106508 KiB |
| 01_test_17.txt | TLE | 2213 ms | 115756 KiB |
| 01_test_18.txt | TLE | 2214 ms | 147552 KiB |
| 01_test_19.txt | TLE | 2214 ms | 147560 KiB |
| 01_test_20.txt | TLE | 2214 ms | 147736 KiB |
| 01_test_21.txt | TLE | 2214 ms | 148040 KiB |
| 01_test_22.txt | TLE | 2214 ms | 148152 KiB |
| 01_test_23.txt | TLE | 2215 ms | 147920 KiB |
| 01_test_24.txt | TLE | 2214 ms | 147832 KiB |
| 01_test_25.txt | TLE | 2214 ms | 147572 KiB |
| 01_test_26.txt | TLE | 2214 ms | 148172 KiB |
| 01_test_27.txt | AC | 57 ms | 76276 KiB |
| 01_test_28.txt | AC | 58 ms | 76532 KiB |
| 01_test_29.txt | AC | 178 ms | 110800 KiB |
| 01_test_30.txt | AC | 108 ms | 82188 KiB |
| 01_test_31.txt | TLE | 2215 ms | 147816 KiB |