結果

問題 No.1147 土偶Ⅱ
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-21 16:43:07
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 12 ms / 500 ms
コード長 1,104 bytes
コンパイル時間 2,605 ms
コンパイル使用メモリ 157,260 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-14 17:21:31
合計ジャッジ時間 4,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 5 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 11 ms
4,352 KB
testcase_07 AC 10 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 9 ms
4,372 KB
testcase_10 AC 5 ms
4,352 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 AC 6 ms
4,352 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 9 ms
4,352 KB
testcase_15 AC 10 ms
4,352 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 12 ms
4,352 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 8 ms
4,356 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>
	var dic2: 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
		do dic.add(a * n + b, true)
		do dic.add(b * n + 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])
					; iとkは友達の友達だが友達ではない
					do dic2.add(i * n + k, true)
					do dic2.add(k * n + i, true)
				end if
			end for
		end for
	end for
	
	var ans: int :: 0
	for i(0, n - 1)
		for j(i + 1, n - 1)
			if(dic2.get(i * n + j, &))
				skip j
			end if
			for k(j + 1, n - 1)
				if(dic2.get(i * n + k, &))
					skip k
				end if
				if(dic2.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