結果

問題 No.812 Change of Class
コンテスト
ユーザー tatt61880
提出日時 2019-04-12 23:18:01
言語 Kuin
(KuinC++ v.2021.9.17)
コンパイル:
kuinc -i _filename_ -o out.cpp -s /kuin/sys/ -e cpp -r -q
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,293 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,802 ms
コンパイル使用メモリ 174,728 KB
実行使用メモリ 30,204 KB
最終ジャッジ日時 2026-04-05 14:57:24
合計ジャッジ時間 10,892 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
out.cpp:676:14: warning: first argument in call to 'memset' is a pointer to non-trivially copyable type 'std::shared_ptr<List_<long>>' [-Wnontrivial-memcall]
  676 |                         memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
      |                                   ^
out.cpp:688:9: note: in instantiation of function template specialization 'newArraysRec_<std::shared_ptr<Array_<std::shared_ptr<List_<long>>>>>::operator()<long>' requested here
  688 |         return newArraysRec_<T>()(std::forward<A>(a)...);
      |                ^
out.cpp:1647:11: note: in instantiation of function template specialization 'newArrays_<std::shared_ptr<Array_<std::shared_ptr<List_<long>>>>, long>' requested here
 1647 | (k_au) = (newArrays_<type_(Array_<type_(List_<int64_t>)>)>((k_ap)));
      |           ^
out.cpp:676:14: note: explicitly cast the pointer to silence this warning
  676 |                         memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
      |                                   ^
      |                                (void*)
out.cpp:676:14: warning: first argument in call to 'memset' is a pointer to non-trivially copyable type 'std::shared_ptr<Array_<long>>' [-Wnontrivial-memcall]
  676 |                         memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
      |                                   ^
out.cpp:688:9: note: in instantiation of function template specialization 'newArraysRec_<std::shared_ptr<Array_<std::shared_ptr<Array_<long>>>>>::operator()<long>' requested here
  688 |         return newArraysRec_<T>()(std::forward<A>(a)...);
      |                ^
out.cpp:1658:11: note: in instantiation of function template specialization 'newArrays_<std::shared_ptr<Array_<std::shared_ptr<Array_<long>>>>, long>' requested here
 1658 | (k_bk) = (newArrays_<type_(Array_<type_(Array_<int64_t>)>)>((k_ap)));
      |           ^
out.cpp:676:14: note: explicitly cast the pointer 

ソースコード

diff #
raw source code

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