結果

問題 No.812 Change of Class
ユーザー 👑 tatt61880tatt61880
提出日時 2019-04-12 23:18:01
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 1,293 bytes
コンパイル時間 3,181 ms
コンパイル使用メモリ 177,928 KB
実行使用メモリ 29,776 KB
最終ジャッジ日時 2023-10-14 15:44:06
合計ジャッジ時間 19,349 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
23,912 KB
testcase_01 AC 28 ms
6,944 KB
testcase_02 AC 97 ms
14,652 KB
testcase_03 AC 210 ms
27,636 KB
testcase_04 AC 185 ms
24,772 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 15 ms
11,100 KB
testcase_08 AC 6 ms
6,184 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 63 ms
24,112 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 53 ms
8,240 KB
testcase_36 AC 20 ms
5,344 KB
testcase_37 AC 130 ms
11,920 KB
testcase_38 AC 24 ms
12,796 KB
testcase_39 AC 130 ms
12,004 KB
testcase_40 AC 32 ms
6,700 KB
testcase_41 AC 20 ms
11,644 KB
testcase_42 AC 378 ms
20,156 KB
testcase_43 AC 91 ms
17,632 KB
testcase_44 AC 229 ms
15,464 KB
testcase_45 AC 19 ms
5,348 KB
testcase_46 AC 87 ms
16,952 KB
testcase_47 AC 242 ms
15,516 KB
testcase_48 AC 290 ms
19,556 KB
testcase_49 AC 53 ms
7,832 KB
testcase_50 AC 4 ms
4,348 KB
testcase_51 AC 62 ms
9,892 KB
testcase_52 AC 142 ms
18,052 KB
testcase_53 AC 34 ms
6,288 KB
testcase_54 AC 28 ms
6,108 KB
testcase_55 AC 148 ms
21,428 KB
testcase_56 AC 180 ms
24,740 KB
testcase_57 AC 186 ms
25,844 KB
testcase_58 AC 95 ms
15,064 KB
testcase_59 AC 212 ms
28,836 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,356 KB
testcase_62 AC 2 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var ss: [][]char
	do ss :: cui@input().split(" ")
	var N: int :: ss[0].toInt(&)
	var M: int :: ss[1].toInt(&)
	var friends: []list<int> :: #[N]list<int>
	for i(0, N - 1)
		do friends[i] :: #list<int>
	end for
	for i(0, M - 1)
		do ss :: cui@input().split(" ")
		var p: int :: ss[0].toInt(&) - 1
		var q: int :: ss[1].toInt(&) - 1
		do friends[p].add(q)
		do friends[q].add(p)
	end for
	var friendsArray: [][]int :: #[N][]int
	for i(0, N - 1)
		do friendsArray[i] :: friends[i].toArray()
	end for
	var Q: int :: cui@input().toInt(&)
	for(1, Q)
		var A: int :: cui@input().toInt(&) - 1
		var people: []int :: #[N]int
		do people[A] :: 1
		var st: stack<int> :: #stack<int>
		do st.add(A)
		var num: int :: 0
		while(^st <> 0)
			var p: int :: st.get()
			for i(0, ^friendsArray[p] - 1)
				var f: int :: friendsArray[p][i]
				if(people[f] = 0)
					do people[f] :: people[p] + 1
					do num :+ 1
					do st.add(f)
				else
					if(people[p] + 1 < people[f])
						do people[f] :: people[p] + 1
					end if
				end if
			end for
		end while
		var len: int :: 0
		for i(0, N - 1)
			if(people[i] > len)
				do len :: people[i]
			end if
		end for
		do len :- 1
		var ans: int :: 0
		while(2 ^ ans < len)
			do ans :+ 1
		end while
		do cui@print("\{num} \{ans}\n")
	end for
end func
0