結果
問題 |
No.812 Change of Class
|
ユーザー |
![]() |
提出日時 | 2020-03-30 22:11:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 313 ms / 4,000 ms |
コード長 | 1,048 bytes |
コンパイル時間 | 2,803 ms |
コンパイル使用メモリ | 198,516 KB |
最終ジャッジ日時 | 2025-01-09 11:07:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 60 |
ソースコード
#include<bits/stdc++.h> using lint=long long; using real=long double; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n,m;std::cin>>n>>m; std::vector<std::vector<lint>>g(n); while(m--){ lint p,q;std::cin>>p>>q;p--,q--; g.at(p).push_back(q); g.at(q).push_back(p); } lint q;std::cin>>q; while(q--){ lint r;std::cin>>r;r--; std::vector<lint>dist(n,-1),que={r}; dist.at(r)=0; for(lint i=0;i<(lint)que.size();i++){ lint x=que.at(i); for(lint y:g.at(x)){ if(dist.at(y)!=-1)continue; dist.at(y)=dist.at(x)+1; que.push_back(y); } } lint sz=std::count_if(dist.begin(),dist.end(),[](lint x){return x!=-1;}); lint d=*std::max_element(dist.begin(),dist.end()); std::cout<<sz-1<<' '<<(d<=1?0:std::numeric_limits<lint>::digits-__builtin_clzll(d-1)+1)<<'\n'; } }