結果
問題 | No.1954 CHECKER×CHECKER(2) |
ユーザー | mkawa2 |
提出日時 | 2024-06-07 21:06:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 78 ms / 1,000 ms |
コード長 | 2,050 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 68,480 KB |
最終ジャッジ日時 | 2024-06-07 21:06:40 |
合計ジャッジ時間 | 2,870 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,096 KB |
testcase_01 | AC | 40 ms
52,096 KB |
testcase_02 | AC | 39 ms
52,352 KB |
testcase_03 | AC | 41 ms
52,352 KB |
testcase_04 | AC | 39 ms
52,352 KB |
testcase_05 | AC | 39 ms
52,224 KB |
testcase_06 | AC | 39 ms
52,096 KB |
testcase_07 | AC | 39 ms
52,352 KB |
testcase_08 | AC | 38 ms
52,736 KB |
testcase_09 | AC | 43 ms
52,096 KB |
testcase_10 | AC | 46 ms
58,240 KB |
testcase_11 | AC | 45 ms
58,496 KB |
testcase_12 | AC | 40 ms
52,096 KB |
testcase_13 | AC | 55 ms
63,488 KB |
testcase_14 | AC | 41 ms
52,608 KB |
testcase_15 | AC | 47 ms
58,752 KB |
testcase_16 | AC | 48 ms
58,496 KB |
testcase_17 | AC | 47 ms
58,496 KB |
testcase_18 | AC | 51 ms
59,648 KB |
testcase_19 | AC | 52 ms
61,312 KB |
testcase_20 | AC | 42 ms
52,992 KB |
testcase_21 | AC | 78 ms
68,480 KB |
testcase_22 | AC | 57 ms
63,744 KB |
testcase_23 | AC | 41 ms
52,736 KB |
testcase_24 | AC | 63 ms
66,432 KB |
testcase_25 | AC | 64 ms
67,584 KB |
testcase_26 | AC | 41 ms
52,736 KB |
testcase_27 | AC | 62 ms
67,072 KB |
testcase_28 | AC | 68 ms
68,480 KB |
testcase_29 | AC | 40 ms
52,352 KB |
testcase_30 | AC | 55 ms
63,872 KB |
testcase_31 | AC | 39 ms
52,352 KB |
ソースコード
import sys # sys.setrecursionlimit(1000006) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = -1-(-1 << 31) # inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 def ok(): fr = [0]*rn fc = [0]*cn fr[0] = f for q, j in enumerate(col): fc[q] = ss[0][j-1] ^ (j-1) & 1 ^ f ^ v for p, i in enumerate(row): if p == 0: continue fr[p] = ss[i-1][0] ^ (i-1) & 1 ^ fc[0] ^ v tt = [[0]*(w+1) for _ in range(h+1)] l = 0 for p, r in enumerate(row): if fr[p]: tt[l][0] ^= 1 tt[r][0] ^= 1 l = r l = 0 for p, r in enumerate(col): if fc[p]: tt[0][l] ^= 1 tt[0][r] ^= 1 l = r for i in range(h): for j in range(w): tt[i][j+1] ^= tt[i][j] for i in range(h): for j in range(w): tt[i+1][j] ^= tt[i][j] # pDB(fr, fc) # p2D(tt) for i in range(h): for j in range(w): if i & 1 ^ j & 1 ^ ss[i][j] ^ tt[i][j] ^ v: return False return True h, w = LI() ss = [[c == "#" for c in SI()] for _ in range(h)] row = [] col = [] for _ in range(II()): t, n = LI() if t == 1: row.append(n) else: col.append(n) if not row: row.append(h) if not col: col.append(w) row.sort() col.sort() rn = len(row) cn = len(col) for f in range(2): for v in range(2): if ok(): print("Yes") exit() print("No")