結果

問題 No.488 四角関係
ユーザー GoryudyumaGoryudyuma
提出日時 2017-03-23 08:59:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 231 ms / 5,000 ms
コード長 2,003 bytes
コンパイル時間 2,826 ms
コンパイル使用メモリ 78,732 KB
実行使用メモリ 58,152 KB
最終ジャッジ日時 2023-09-19 08:42:25
合計ジャッジ時間 8,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
55,660 KB
testcase_01 AC 209 ms
57,140 KB
testcase_02 AC 182 ms
55,788 KB
testcase_03 AC 167 ms
55,720 KB
testcase_04 AC 201 ms
56,496 KB
testcase_05 AC 206 ms
56,536 KB
testcase_06 AC 182 ms
57,272 KB
testcase_07 AC 217 ms
56,772 KB
testcase_08 AC 231 ms
58,152 KB
testcase_09 AC 135 ms
55,380 KB
testcase_10 AC 157 ms
55,628 KB
testcase_11 AC 142 ms
55,424 KB
testcase_12 AC 159 ms
55,348 KB
testcase_13 AC 147 ms
55,376 KB
testcase_14 AC 141 ms
55,372 KB
testcase_15 AC 137 ms
55,568 KB
testcase_16 AC 134 ms
55,424 KB
testcase_17 AC 130 ms
55,420 KB
testcase_18 AC 134 ms
55,372 KB
testcase_19 AC 136 ms
55,680 KB
testcase_20 AC 132 ms
55,608 KB
testcase_21 AC 131 ms
55,628 KB
testcase_22 AC 132 ms
53,480 KB
testcase_23 AC 132 ms
55,200 KB
testcase_24 AC 137 ms
55,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt(), M = sc.nextInt();
                        boolean[][] f = new boolean[N][N];
                        for (int i = 0; i < M; i++) {
                                int a = sc.nextInt(), b = sc.nextInt();
                                f[a][b] = true;
                                f[b][a] = true;
                        }
                        int ans = 0;
                        for (int i = 0; i < N; i++) {
                                for (int j = i + 1; j < N; j++) {
                                        for (int k = j + 1; k < N; k++) {
                                                for (int l = k + 1; l < N; l++) {
                                                        if (f[i][j]) {
                                                                if (f[i][k] && f[k][l] && f[l][j] && !f[i][l] && !f[j][k]) {
                                                                        ans++;
                                                                } else if(f[i][l] && f[k][l] && f[k][j] && !f[i][k] && !f[j][l])     {
                                                                        ans++;
                                                                }
                                                        } else {
                                                                if (!f[k][l] && f[i][k] &&f[i][l] && f[j][k] && f[j][l]) {
                                                                        ans++;
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                        System.out.println(ans);
                }
        }
}
0