結果

問題 No.2678 Minmax Independent Set (Hack)
ユーザー 👑 nu50218nu50218
提出日時 2024-03-14 15:15:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 100,332 KB
最終ジャッジ日時 2024-03-14 15:15:22
合計ジャッジ時間 1,837 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
100,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/pypy3

from collections import deque

N = 199993
L = 39999

G = [[] for i in range(N + 1)]
p = 6000

for i in range(1, L):
    G[i].append(i + 1)
    G[i + 1].append(i)

id = L + 1

for u in range(1, L + 1):
    now = u

    if u == p: # 縦に 3 つ
        G[now].append(id)
        G[id].append(now)
        id += 1
        G[now].append(id)
        G[id].append(now)
        id += 1
    else:  # 縦に 5 つ
        G[now].append(id)
        G[id].append(now)
        now = id
        id += 1
        G[now].append(id)
        G[id].append(now)
        id += 1

        now = u
        G[now].append(id)
        G[id].append(now)
        now = id
        id += 1
        G[now].append(id)
        G[id].append(now)
        id += 1

S = deque()
S.append(1)
visited = [False] * (N + 1)

print(N)

while len(S) > 0:
    now = S.pop()
    visited[now] = True

    for nx in G[now]:
        if visited[nx]:
          continue
        print(min(now, nx), max(now, nx))
        S.append(nx)
0