結果

問題 No.488 四角関係
ユーザー te-shte-sh
提出日時 2017-12-11 17:19:31
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 231 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 88,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 17:27:55
合計ジャッジ時間 3,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
4,380 KB
testcase_01 AC 59 ms
4,380 KB
testcase_02 AC 85 ms
4,380 KB
testcase_03 AC 29 ms
4,380 KB
testcase_04 AC 45 ms
4,380 KB
testcase_05 AC 103 ms
4,380 KB
testcase_06 AC 181 ms
4,376 KB
testcase_07 AC 197 ms
4,380 KB
testcase_08 AC 231 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 19 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 16 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
}
0