結果
問題 | No.488 四角関係 |
ユーザー |
|
提出日時 | 2017-02-25 02:05:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 311 ms / 5,000 ms |
コード長 | 587 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-01-03 08:34:31 |
合計ジャッジ時間 | 3,362 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
from itertools import combinationsn, m = tuple(int(x) for x in input().split())mtx = [[False for _ in range(n)] for _ in range(n)]for _ in range(m):a, b = tuple(int(x) for x in input().split())mtx[a][b] = mtx[b][a] = Truedef check_square(i, j, k, l):return mtx[i][j] and mtx[j][k] and mtx[k][l] and mtx[l][i] and not mtx[i][k] and not mtx[j][l]cnt = 0for i, j, k, l in combinations(range(n), 4):if check_square(i, j, k, l):cnt += 1elif check_square(i, k, j, l):cnt += 1elif check_square(i, j, l, k):cnt += 1print(cnt)