結果
| 問題 |
No.488 四角関係
|
| ユーザー |
|
| 提出日時 | 2024-12-24 07:39:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 196 ms / 5,000 ms |
| コード長 | 964 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,204 KB |
| 実行使用メモリ | 77,760 KB |
| 最終ジャッジ日時 | 2024-12-24 07:39:46 |
| 合計ジャッジ時間 | 3,438 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
from collections import deque
N,M = map(int,input().split())
G = {i:set() for i in range(N)}
for _ in range(M):
a,b = map(int,input().split())
G[a].add(b)
G[b].add(a)
ans = 0
for i in range(N-3):
for j in range(i+1,N-2):
for k in range(j+1,N-1):
for l in range(k+1,N):
if len(G[i]&set([j,k,l]))==2 and len(G[j]&set([i,k,l]))==2 and len(G[k]&set([i,j,l]))==2 and len(G[l]&set([i,j,k]))==2:
col = {i:1,j:0,k:0,l:0}
que = deque([i])
while que:
x = que.popleft()
A = set([i,j,k,l])
A.remove(x)
for y in G[x]&A:
if col[y]==0:
col[y] = 1
que.append(y)
if sum(col.values())==4:
ans += 1
else:continue
print(ans)