結果
問題 | No.812 Change of Class |
ユーザー |
![]() |
提出日時 | 2019-04-12 22:56:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 163 ms / 4,000 ms |
コード長 | 2,304 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 173,352 KB |
実行使用メモリ | 9,592 KB |
最終ジャッジ日時 | 2024-06-12 19:47:33 |
合計ジャッジ時間 | 7,317 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 60 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long signed int LL;typedef long long unsigned int LU;#define incII(i, l, r) for(int i = (l) ; i <= (r); ++i)#define incID(i, l, r) for(int i = (l) ; i < (r); ++i)#define decII(i, l, r) for(int i = (r) ; i >= (l); --i)#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)#define inc(i, n) incID(i, 0, n)#define inc1(i, n) incII(i, 1, n)#define dec(i, n) decID(i, 0, n)#define dec1(i, n) decII(i, 1, n)#define inII(v, l, r) ((l) <= (v) && (v) <= (r))#define inID(v, l, r) ((l) <= (v) && (v) < (r))#define PB push_back#define EB emplace_back#define MP make_pair#define FI first#define SE second#define ALL(v) v.begin(), v.end()#define RALL(v) v.rbegin(), v.rend()template<typename T> bool setmin (T & a, T b) { if(b < a) { a = b; return true; } else { return false; } }template<typename T> bool setmax (T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }#define bit(b, i) (((b) >> (i)) & 1)#define BC __builtin_popcountll#define SC(T, v) static_cast<T>(v)#define SI(v) SC(int, v.size())#define SL(v) SC( LL, v.size())#define RF(e, v) for(auto & e: v)#define ei else if#define UR assert(false)// ---- ----int n, m, Q;vector<int> g[100000];int f(int x) {int c = 0;while(! (x <= (1 << c))) { c++; }return c;}int main() {cin >> n >> m;inc(i, m) {int a, b;cin >> a >> b;a--; b--;g[a].PB(b);g[b].PB(a);}cin >> Q;inc(QQ, Q) {int a;cin >> a;a--;int c = 0, dma = 0;vector<int> d(n, n);queue<int> q;q.push(a);d[a] = 0;c++;while(! q.empty()) {int p = q.front(); q.pop();RF(e, g[p]) {if(d[e] == n) { c++; }if(setmin(d[e], d[p] + 1)) { q.push(e); setmax(dma, d[e]); }}}cout << c - 1 << " " << f(dma) << "\n";}return 0;}