結果

問題 No.1147 土偶Ⅱ
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-21 16:50:43
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 11 ms / 500 ms
コード長 1,132 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 155,972 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 17:21:35
合計ジャッジ時間 3,215 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var m: int :: cui@inputInt()
	var data: [][]bool :: #[n, n]bool
	var dic: dict<int, bool> :: #dict<int, bool>
	for(1, m)
		var a: int :: cui@inputInt()
		var b: int :: cui@inputInt()
		do a :- 1
		do b :- 1
		do data[a][b] :: true
		do data[b][a] :: true
	end for
	for i(0, n - 1)
		for j(0, n - 1)
			if(!data[i][j])
				skip j
			end if
			; iとjは友達。
			for k(0, n - 1)
				if(!data[j][k])
					skip k
				end if
				; jとkは友達。
				
				if(data[i][k])
					skip k
				end if
				; iとkは「友達」ではない。
				
				; iとkは「友達の友達」。
				; ※「友達の友達」であるためには、「友達」ではないことが必要
				do dic.add(i * n + k, true)
				do dic.add(k * n + i, true)
			end for
		end for
	end for
	
	var ans: int :: 0
	for i(0, n - 1)
		for j(i + 1, n - 1)
			if(dic.get(i * n + j, &))
				skip j
			end if
			for k(j + 1, n - 1)
				if(dic.get(i * n + k, &))
					skip k
				end if
				if(dic.get(j * n + k, &))
					skip k
				end if
				do ans :+ 1
			end for
		end for
	end for
	do cui@print("\{ans}\n")
end func
0