結果

問題 No.488 四角関係
ユーザー rpy3cpprpy3cpp
提出日時 2017-03-26 00:50:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 806 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 9,380 KB
最終ジャッジ日時 2023-09-20 10:49:44
合計ジャッジ時間 1,619 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,932 KB
testcase_01 AC 34 ms
8,596 KB
testcase_02 AC 23 ms
8,380 KB
testcase_03 AC 21 ms
8,252 KB
testcase_04 AC 23 ms
8,404 KB
testcase_05 AC 36 ms
8,512 KB
testcase_06 AC 17 ms
7,836 KB
testcase_07 AC 73 ms
9,380 KB
testcase_08 AC 25 ms
8,280 KB
testcase_09 AC 16 ms
7,784 KB
testcase_10 AC 17 ms
7,832 KB
testcase_11 AC 16 ms
7,832 KB
testcase_12 AC 20 ms
8,248 KB
testcase_13 AC 18 ms
7,824 KB
testcase_14 AC 16 ms
7,824 KB
testcase_15 AC 15 ms
7,840 KB
testcase_16 AC 15 ms
7,836 KB
testcase_17 AC 15 ms
7,856 KB
testcase_18 AC 16 ms
7,804 KB
testcase_19 AC 15 ms
7,896 KB
testcase_20 AC 15 ms
7,912 KB
testcase_21 AC 16 ms
7,848 KB
testcase_22 AC 16 ms
7,896 KB
testcase_23 AC 15 ms
7,784 KB
testcase_24 AC 16 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, M = map(int, input().split())
    Es = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        Es[a].add(b)
        Es[b].add(a)
    return N, M, Es

def solve(N, M, Es):
    pool = set()
    for a in range(N):
        for b in Es[a]:
            for c in Es[b]:
                if c == a:
                    continue
                if a in Es[c]:
                    continue
                for d in Es[c]:
                    if d == b:
                        continue
                    if a not in Es[d]:
                        continue
                    if b in Es[d]:
                        continue
                    pool.add(tuple(sorted([a, b, c, d])))
    return len(pool)

N, M, Es = read_data()
print(solve(N, M, Es))
0