結果

問題 No.488 四角関係
ユーザー いともたやすく行われるえげつない行為いともたやすく行われるえげつない行為
提出日時 2017-02-25 13:32:52
言語 Go
(1.22.1)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,099 bytes
コンパイル時間 11,919 ms
コンパイル使用メモリ 214,188 KB
実行使用メモリ 5,756 KB
最終ジャッジ日時 2023-09-02 08:00:40
合計ジャッジ時間 13,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// yukicoder no.488 main.go
// #D 
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func check(edge [][]bool, p1, p2, p3, p4 int) bool {
	if edge[p1][p3] || edge[p2][p4] {
		return false
	}
	return edge[p4][p1] && edge[p1][p2] && edge[p2][p3] && edge[p3][p4]
}

func solve(in io.Reader, out, err io.Writer) {
	num, num_edge := 0, 0
	fmt.Fscan(in, &num, &num_edge)
	edgeTable := make([][]bool, num)
	for i := range edgeTable {
		edgeTable[i] = make([]bool, num)
	}

	for i := 0; i < num_edge; i++ {
		a, b := 0, 0
		fmt.Fscan(in, &a, &b)
		edgeTable[a][b], edgeTable[b][a] = true, true
	}

	count := 0
	for i := 0; i < num; i++ {
		for jj := i + 1; jj < num; jj++ {
			for kkk := jj + 1; kkk < num; kkk++ {
				for LLLL := kkk + 1; LLLL < num; LLLL++ {
					if check(edgeTable, i, jj, kkk, LLLL) {
						count++
					}
					if check(edgeTable, i, kkk, LLLL, jj) {
						count++
					}
					if check(edgeTable, i, LLLL, jj, kkk) {
						count++
					}
				}
			}
		}
	}

	fmt.Fprintln(out, count)
}

func main() {
	br := bufio.NewReaderSize(os.Stdin, int(1e7))
	solve(br, os.Stdout, os.Stderr)
}
0