結果

問題 No.812 Change of Class
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-24 19:13:10
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 353 ms / 4,000 ms
コード長 1,260 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 166,404 KB
実行使用メモリ 28,244 KB
最終ジャッジ日時 2023-10-14 16:23:55
合計ジャッジ時間 12,406 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
22,804 KB
testcase_01 AC 27 ms
6,528 KB
testcase_02 AC 90 ms
14,004 KB
testcase_03 AC 195 ms
26,148 KB
testcase_04 AC 172 ms
23,612 KB
testcase_05 AC 353 ms
25,680 KB
testcase_06 AC 303 ms
20,964 KB
testcase_07 AC 14 ms
10,272 KB
testcase_08 AC 6 ms
6,140 KB
testcase_09 AC 340 ms
28,244 KB
testcase_10 AC 345 ms
28,160 KB
testcase_11 AC 51 ms
22,416 KB
testcase_12 AC 238 ms
26,768 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 220 ms
19,424 KB
testcase_16 AC 15 ms
5,144 KB
testcase_17 AC 213 ms
20,804 KB
testcase_18 AC 155 ms
15,876 KB
testcase_19 AC 180 ms
18,252 KB
testcase_20 AC 345 ms
27,504 KB
testcase_21 AC 144 ms
15,644 KB
testcase_22 AC 65 ms
9,164 KB
testcase_23 AC 12 ms
4,784 KB
testcase_24 AC 19 ms
5,524 KB
testcase_25 AC 52 ms
8,096 KB
testcase_26 AC 283 ms
23,524 KB
testcase_27 AC 245 ms
21,252 KB
testcase_28 AC 176 ms
18,016 KB
testcase_29 AC 38 ms
6,816 KB
testcase_30 AC 217 ms
20,364 KB
testcase_31 AC 189 ms
17,428 KB
testcase_32 AC 85 ms
10,872 KB
testcase_33 AC 241 ms
22,620 KB
testcase_34 AC 18 ms
5,268 KB
testcase_35 AC 45 ms
7,872 KB
testcase_36 AC 17 ms
5,420 KB
testcase_37 AC 104 ms
11,540 KB
testcase_38 AC 20 ms
11,924 KB
testcase_39 AC 109 ms
11,656 KB
testcase_40 AC 28 ms
6,312 KB
testcase_41 AC 17 ms
10,624 KB
testcase_42 AC 237 ms
19,384 KB
testcase_43 AC 69 ms
16,476 KB
testcase_44 AC 162 ms
14,740 KB
testcase_45 AC 18 ms
5,388 KB
testcase_46 AC 65 ms
15,992 KB
testcase_47 AC 156 ms
15,248 KB
testcase_48 AC 181 ms
18,032 KB
testcase_49 AC 45 ms
7,424 KB
testcase_50 AC 4 ms
4,352 KB
testcase_51 AC 51 ms
9,356 KB
testcase_52 AC 105 ms
16,976 KB
testcase_53 AC 30 ms
6,060 KB
testcase_54 AC 25 ms
5,828 KB
testcase_55 AC 127 ms
20,472 KB
testcase_56 AC 151 ms
23,328 KB
testcase_57 AC 160 ms
24,616 KB
testcase_58 AC 83 ms
14,668 KB
testcase_59 AC 187 ms
27,248 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,352 KB
testcase_62 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var N: int :: cui@inputInt()
	var M: int :: cui@inputInt()
	var friendList: []list<int> :: #[N]list<int>
	for i(0, N - 1)
		do friendList[i] :: #list<int>
	end for
	for i(0, M - 1)
		var p: int :: cui@inputInt() - 1
		var q: int :: cui@inputInt() - 1
		do friendList[p].add(q)
		do friendList[q].add(p)
	end for
	var friendArray: [][]int :: #[N][]int
	for i(0, N - 1)
		do friendArray[i] :: friendList[i].toArray()
	end for
	var Q: int :: cui@inputInt()
	
	var que: queue<int> :: #queue<int>
	var people: []int :: #[N]int
	for(1, Q)
		for i(0, N - 1)
			do people[i] :: 0
		end for
		var A: int :: cui@inputInt() - 1
		do people[A] :: 1
		do que.add(A)
		var num: int :: 0
		while(^que <> 0)
			var p: int :: que.get()
			for i(0, ^friendArray[p] - 1)
				var f: int :: friendArray[p][i]
				if(people[f] = 0)
					do people[f] :: people[p] + 1
					do num :+ 1
					do que.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