結果
| 問題 | No.3341 Making Beautiful Graphs |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-01-29 16:58:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,052 bytes |
| 記録 | |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 78,976 KB |
| 最終ジャッジ日時 | 2026-01-29 16:59:01 |
| 合計ジャッジ時間 | 7,200 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 48 RE * 1 |
ソースコード
from collections import deque
from random import randrange
N = int(input())
if N == 2:
exit(print(-1))
def MOD1(a):
while N2 < a:
a -= N2
return a
N2 = N**2
while True:
a, b, c, d = randrange(1, N2), randrange(1, N2), randrange(1, N2), randrange(1, N2)
if len(set([a, b, c, d])) < 4:
continue
if (a+b+c+d)%4 != 0:
continue
edge = []
for i in range(1, N2+1):
E = [i+a, i+b, i+c, i+d]
for j in range(4):
E[j] = MOD1(E[j])
for e in E:
edge.append((i, e))
G = [[] for _ in range(N2)]
for u, v in edge:
u, v = u-1, v-1
G[u].append(v)
visited = [-1]*N2
visited[0] = 0
que = deque()
que.append(0)
while que:
n = que.popleft()
for v in G[n]:
if visited[v] == -1:
visited[v] = visited[n]+1
que.append(v)
if max(visited) <= N:
print(len(edge)//2)
for u, v in edge:
if u < v:
print(u, v)
break
detteiuu