結果

問題 No.488 四角関係
ユーザー yuki2006yuki2006
提出日時 2017-02-26 15:32:27
言語 Go
(1.21.3)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 931 bytes
コンパイル時間 10,972 ms
コンパイル使用メモリ 211,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 09:59:08
合計ジャッジ時間 12,176 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

package main

import "fmt"

func checkSquare(edge [][]bool, i, j, k, l int) bool {
	return edge[i][j] && edge[j][k] && edge[k][l] && edge[l][i] && !edge[i][k] && !edge[j][l]

}

func main() {

	var N int
	var M int

	fmt.Scan(&N, &M)

	edge := make([][]bool, N)
	for i := 0; i < N; i++ {
		edge[i] = make([]bool, N)
	}

	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		edge[a][b] = true
		edge[b][a] = true
	}
	count := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := j + 1; k < N; k++ {
				for l := k + 1; l < N; l++ {
					if checkSquare(edge, i, j, k, l) {
						count++
					}
					if checkSquare(edge, i, k, l, j) {
						count++
					}
					if checkSquare(edge, i, l, j, k) {
						count++
					}
					// それ以外の並び替えは 同じ意味を持つためカウントしない
					//if checkSquare(edge,i,j,l,k){
					//	count++
					//}
				}
			}
		}
	}
	fmt.Println(count)

}
0