結果

問題 No.488 四角関係
ユーザー YamaKasaYamaKasa
提出日時 2018-09-24 15:02:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 199 ms / 5,000 ms
コード長 984 bytes
コンパイル時間 5,457 ms
コンパイル使用メモリ 76,668 KB
実行使用メモリ 60,116 KB
最終ジャッジ日時 2023-10-22 01:53:32
合計ジャッジ時間 8,220 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
57,616 KB
testcase_01 AC 179 ms
57,800 KB
testcase_02 AC 179 ms
57,640 KB
testcase_03 AC 143 ms
57,680 KB
testcase_04 AC 149 ms
57,500 KB
testcase_05 AC 184 ms
57,820 KB
testcase_06 AC 162 ms
57,660 KB
testcase_07 AC 195 ms
58,236 KB
testcase_08 AC 199 ms
60,116 KB
testcase_09 AC 124 ms
57,724 KB
testcase_10 AC 132 ms
57,632 KB
testcase_11 AC 124 ms
57,348 KB
testcase_12 AC 144 ms
57,744 KB
testcase_13 AC 129 ms
57,508 KB
testcase_14 AC 125 ms
57,512 KB
testcase_15 AC 125 ms
57,408 KB
testcase_16 AC 109 ms
56,204 KB
testcase_17 AC 124 ms
57,652 KB
testcase_18 AC 122 ms
57,416 KB
testcase_19 AC 122 ms
57,748 KB
testcase_20 AC 115 ms
57,088 KB
testcase_21 AC 124 ms
57,592 KB
testcase_22 AC 118 ms
57,312 KB
testcase_23 AC 122 ms
57,348 KB
testcase_24 AC 123 ms
57,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[]a = new int[M];
		int[]b = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		scan.close();
		if(M < 4 || N < 4) {
			System.out.println(0);
			System.exit(0);
		}
		int[][]G = new int[N][N];
		for(int i = 0; i < M; i++) {
			G[a[i]][b[i]] = 1;
			G[b[i]][a[i]] = 1;
		}
		int cnt = 0;
		for(int i = 0; i < N - 3; i++) {
			for(int j = i + 1; j < N - 2; j++) {
				for(int k = j + 1; k < N - 1; k++) {
					for(int l = k + 1; l < N; l++) {
						int d1 = G[i][j] + G[i][k] + G[i][l];
						int d2 = G[j][i] + G[j][k] + G[j][l];
						int d3 = G[k][i] + G[k][j] + G[k][l];
						int d4 = G[l][i] + G[l][j] + G[l][k];
						if(d1 == 2 && d2 == 2 && d3 == 2 && d4 == 2) {
							cnt ++;
						}
					}
				}
			}
		}
		System.out.println(cnt);
	}
}
0