結果

問題 No.1566 All Even
ユーザー mkawa2mkawa2
提出日時 2021-06-28 10:41:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,863 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 8,612 KB
最終ジャッジ日時 2023-09-07 18:18:10
合計ジャッジ時間 2,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,100 KB
testcase_01 AC 17 ms
8,308 KB
testcase_02 AC 111 ms
8,108 KB
testcase_03 AC 16 ms
8,468 KB
testcase_04 AC 17 ms
7,984 KB
testcase_05 AC 16 ms
8,388 KB
testcase_06 AC 16 ms
8,528 KB
testcase_07 AC 17 ms
8,452 KB
testcase_08 AC 20 ms
7,988 KB
testcase_09 AC 17 ms
8,540 KB
testcase_10 AC 33 ms
8,172 KB
testcase_11 AC 17 ms
8,560 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 20 ms
8,100 KB
testcase_18 AC 17 ms
8,108 KB
testcase_19 AC 17 ms
8,072 KB
testcase_20 AC 17 ms
8,096 KB
testcase_21 AC 17 ms
8,152 KB
testcase_22 WA -
testcase_23 AC 17 ms
8,100 KB
testcase_24 WA -
testcase_25 AC 16 ms
8,116 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 16 ms
8,388 KB
testcase_29 AC 16 ms
8,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# 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 = 10**16
md = 998244353
# md = 10**9+7

n,m=LI()
xyz=LLI(m)

if n>=7:
    for x,y,z in xyz:
        if z==1:
            print(0)
            exit()
    print(1)
    exit()

xyz=[(x-1,y-1,z) for x,y,z in xyz]
ans=0
for bit in range(1 << 2*n-1):
    tt = [[0]*n for _ in range(n)]
    for i in range(n):
        tt[i][0] = bit >> i & 1
    for j in range(1, n):
        tt[0][j] = bit >> j+n-1 & 1
    for i in range(1, n):
        for j in range(1, n):
            s = tt[i-1][j-1] ^ tt[i][j-1] ^ tt[i-1][j]
            tt[i][j] = s

    cs = [[0]*(n+1) for _ in range(n+1)]
    for i in range(n):
        for j in range(n):
            cs[i+1][j+1] = cs[i+1][j] ^ tt[i][j]
    for j in range(n):
        for i in range(n):
            cs[i+1][j+1] ^= cs[i][j+1]

    def ok():
        for x,y,z in xyz:
            if tt[x][y]!=z:return False
        for d in range(3, n+1):
            for i in range(n-d+1):
                for j in range(n-d+1):
                    x = cs[i][j] ^ cs[i+d][j+d] ^ cs[i+d][j] ^ cs[i][j+d]
                    if x: return False
        return True

    # print("OK" if ok() else "NG")
    if ok():
        ans+=1
        # p2D(tt)
        # print()

print(ans)
0