結果
問題 |
No.488 四角関係
|
ユーザー |
|
提出日時 | 2018-08-31 21:33:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,709 ms / 5,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 44,480 KB |
最終ジャッジ日時 | 2024-09-13 22:46:41 |
合計ジャッジ時間 | 18,038 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import numpy as np from itertools import combinations n, m = tuple(int(x) for x in input().split()) mtx = np.zeros((n, n)) for _ in range(m): a, b = tuple(int(x) for x in input().split()) mtx[a][b] = mtx[b][a] = True def 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 = 0 for i, j, k, l in combinations(range(n), 4): if check_square(i, j, k, l): cnt += 1 elif check_square(i, k, j, l): cnt += 1 elif check_square(i, j, l, k): cnt += 1 print(cnt)