結果
| 問題 |
No.812 Change of Class
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-12 19:41:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 173 ms / 4,000 ms |
| コード長 | 673 bytes |
| コンパイル時間 | 703 ms |
| コンパイル使用メモリ | 79,500 KB |
| 実行使用メモリ | 10,320 KB |
| 最終ジャッジ日時 | 2024-06-12 21:23:51 |
| 合計ジャッジ時間 | 6,257 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
vector<int>G[1<<17];
main()
{
cin>>N>>M;
for(int i=0;i<M;i++)
{
int u,v;cin>>u>>v;
u--,v--;
G[u].push_back(v);
G[v].push_back(u);
}
int Q;cin>>Q;
for(;Q--;)
{
int A;cin>>A;A--;
vector<int>dis(N,1e9);
dis[A]=0;
queue<int>P;
P.push(A);
while(!P.empty())
{
int u=P.front();P.pop();
for(int v:G[u])
{
if(dis[v]>dis[u]+1)
{
dis[v]=dis[u]+1;
P.push(v);
}
}
}
int x=0,cnt=0;
for(int i=0;i<N;i++)
{
if(dis[i]<1e9)x=max(x,dis[i]),cnt++;
}
int L=0;
while(x>1<<L)L++;
cout<<cnt-1<<" "<<L<<endl;
}
}