結果

問題 No.488 四角関係
ユーザー 👑 yumechiyumechi
提出日時 2017-02-25 01:54:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,019 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 112,768 KB
最終ジャッジ日時 2023-09-01 21:57:56
合計ジャッジ時間 9,462 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 231 ms
112,596 KB
testcase_01 AC 415 ms
112,424 KB
testcase_02 AC 295 ms
112,672 KB
testcase_03 AC 303 ms
112,712 KB
testcase_04 AC 346 ms
112,480 KB
testcase_05 AC 403 ms
112,124 KB
testcase_06 AC 232 ms
112,628 KB
testcase_07 AC 607 ms
112,212 KB
testcase_08 AC 1,019 ms
102,488 KB
testcase_09 AC 166 ms
112,388 KB
testcase_10 AC 270 ms
112,440 KB
testcase_11 AC 225 ms
112,528 KB
testcase_12 AC 362 ms
112,076 KB
testcase_13 AC 278 ms
112,652 KB
testcase_14 AC 227 ms
112,364 KB
testcase_15 AC 180 ms
112,356 KB
testcase_16 AC 185 ms
112,576 KB
testcase_17 AC 173 ms
112,560 KB
testcase_18 AC 199 ms
112,612 KB
testcase_19 AC 203 ms
112,620 KB
testcase_20 AC 178 ms
112,536 KB
testcase_21 AC 170 ms
112,624 KB
testcase_22 AC 187 ms
112,448 KB
testcase_23 AC 176 ms
112,768 KB
testcase_24 AC 208 ms
112,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import itertools


def solve():
	n, m = map(int, input().split())
	node_pair = []
	
	for _ in range(m):
		a, b = map(int, input().split())
		node_pair.append([a, b])
	
	node_dict = defaultdict(list)
	for pair in node_pair:
		node_dict[pair[0]].append(pair[1])
		node_dict[pair[1]].append(pair[0])
	
	ans = 0
	for square in list(itertools.combinations(range(0, 51), 4)):
		for idx in range(4):
			connection_count = 0
			for node in node_dict[square[idx]]:
				if node in square:
					connection_count += 1
			if connection_count != 2:
				break
		else:
			ans += 1
	print(ans)


if __name__=="__main__":
    solve()
0