結果
問題 | No.488 四角関係 |
ユーザー |
|
提出日時 | 2017-12-11 17:19:31 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 237 ms / 5,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 102,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 23:00:13 |
合計ジャッジ時間 | 2,791 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;void main(){auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1];auto g = new bool[][](n, n);foreach (i; 0..m) {auto rd2 = readln.split.to!(int[]), a = rd2[0], b = rd2[1];g[a][b] = g[b][a] = true;}auto isSquare(int[] e){do {if (g[e[0]][e[1]] && g[e[1]][e[2]] && g[e[2]][e[3]] && g[e[3]][e[0]] &&!g[e[0]][e[2]] && !g[e[1]][e[3]])return true;} while (e.nextPermutation);return false;}auto ans = 0;foreach (e1; 0..n)foreach (e2; e1+1..n)foreach (e3; e2+1..n)foreach (e4; e3+1..n)ans += isSquare([e1,e2,e3,e4]);writeln(ans);}