結果
| 問題 | No.812 Change of Class |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-29 23:19:26 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 4,000 ms |
| コード長 | 1,280 bytes |
| 記録 | |
| コンパイル時間 | 1,104 ms |
| コンパイル使用メモリ | 118,772 KB |
| 実行使用メモリ | 9,988 KB |
| 最終ジャッジ日時 | 2026-03-08 19:29:27 |
| 合計ジャッジ時間 | 4,947 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d %d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> v(n);
for (int i = 0; i < m; ++i) {
int a, b;
scanf("%d %d", &a, &b);
a--; b--;
v[a].emplace_back(b);
v[b].emplace_back(a);
}
int q;
cin >> q;
while(q--){
int a;
cin >> a;
queue<int> s;
vector<int> visited(n), ans(n);
s.emplace(a-1);
int p = 0;
visited[a-1]++;
while(!s.empty()){
int x = s.front(); s.pop();
for (auto &&i : v[x]) {
if(!visited[i]) {
visited[i]++;
s.emplace(i);
ans[i] = ans[x]+1;
p++;
}
}
}
int anss = 0, mans = *max_element(ans.begin(),ans.end());
while(1<<anss < mans) anss++;
cout << p << " " << anss << "\n";
}
return 0;
}