結果
| 問題 |
No.2678 Minmax Independent Set (Hack)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-14 15:15:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 186 ms / 2,000 ms |
| コード長 | 1,000 bytes |
| コンパイル時間 | 154 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 101,248 KB |
| 最終ジャッジ日時 | 2024-09-29 23:43:14 |
| 合計ジャッジ時間 | 1,252 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
ソースコード
#!/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)