結果

問題 No.1777 万華鏡美術館
ユーザー mkawa2mkawa2
提出日時 2021-12-09 12:09:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,223 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 8,248 KB
最終ジャッジ日時 2023-09-24 05:28:59
合計ジャッジ時間 1,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,084 KB
testcase_01 AC 17 ms
8,044 KB
testcase_02 AC 16 ms
7,976 KB
testcase_03 AC 16 ms
8,100 KB
testcase_04 AC 15 ms
8,128 KB
testcase_05 AC 15 ms
7,804 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 14 ms
7,972 KB
testcase_10 AC 15 ms
8,032 KB
testcase_11 AC 16 ms
8,120 KB
testcase_12 AC 14 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(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 = 18446744073709551615
# inf = 4294967295
# md = 10**9+7
# md = 998244353
md = 10**8+9

def is4():
    if m == 0: return n & 1 == 0
    if s == -1: return False
    u = s
    while 1:
        v = to[u]
        d = v-u
        if d < 0: d += n
        if v == -1: return False
        if d & 1 == 0: return False
        if v == s: return True
        u = v

n, m = LI()

to = [-1]*n
s = -1
for _ in range(m):
    u, v = LI1()
    if to[u] == -1:
        to[u] = v
    else:
        to[u], to[max(to[u], v)] = min(to[u], v), u
        s = u

print(4 if is4() else 5)
0