結果

問題 No.812 Change of Class
ユーザー kjnh10kjnh10
提出日時 2019-04-12 23:44:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,151 ms / 4,000 ms
コード長 2,512 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 175,580 KB
実行使用メモリ 13,840 KB
最終ジャッジ日時 2023-09-03 14:15:12
合計ジャッジ時間 22,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
8,540 KB
testcase_01 AC 23 ms
4,380 KB
testcase_02 AC 79 ms
6,144 KB
testcase_03 AC 168 ms
9,644 KB
testcase_04 AC 149 ms
9,016 KB
testcase_05 AC 1,089 ms
11,984 KB
testcase_06 AC 1,151 ms
11,992 KB
testcase_07 AC 6 ms
4,636 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 863 ms
12,368 KB
testcase_10 AC 971 ms
12,556 KB
testcase_11 AC 19 ms
7,744 KB
testcase_12 AC 569 ms
11,064 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 687 ms
8,980 KB
testcase_16 AC 36 ms
4,376 KB
testcase_17 AC 584 ms
9,568 KB
testcase_18 AC 417 ms
7,996 KB
testcase_19 AC 469 ms
8,592 KB
testcase_20 AC 1,000 ms
12,116 KB
testcase_21 AC 393 ms
7,764 KB
testcase_22 AC 166 ms
5,728 KB
testcase_23 AC 27 ms
4,376 KB
testcase_24 AC 45 ms
4,380 KB
testcase_25 AC 135 ms
5,124 KB
testcase_26 AC 769 ms
10,660 KB
testcase_27 AC 667 ms
9,808 KB
testcase_28 AC 432 ms
8,612 KB
testcase_29 AC 105 ms
4,664 KB
testcase_30 AC 615 ms
9,544 KB
testcase_31 AC 531 ms
8,436 KB
testcase_32 AC 209 ms
6,064 KB
testcase_33 AC 595 ms
10,080 KB
testcase_34 AC 40 ms
4,424 KB
testcase_35 AC 88 ms
4,604 KB
testcase_36 AC 45 ms
4,380 KB
testcase_37 AC 259 ms
5,580 KB
testcase_38 AC 8 ms
5,160 KB
testcase_39 AC 268 ms
5,576 KB
testcase_40 AC 57 ms
4,376 KB
testcase_41 AC 7 ms
4,512 KB
testcase_42 AC 568 ms
8,508 KB
testcase_43 AC 41 ms
6,744 KB
testcase_44 AC 394 ms
6,876 KB
testcase_45 AC 46 ms
4,376 KB
testcase_46 AC 34 ms
6,732 KB
testcase_47 AC 385 ms
6,744 KB
testcase_48 AC 363 ms
7,528 KB
testcase_49 AC 123 ms
4,836 KB
testcase_50 AC 7 ms
4,376 KB
testcase_51 AC 89 ms
4,992 KB
testcase_52 AC 155 ms
6,940 KB
testcase_53 AC 77 ms
4,376 KB
testcase_54 AC 70 ms
4,552 KB
testcase_55 AC 357 ms
10,400 KB
testcase_56 AC 441 ms
12,396 KB
testcase_57 AC 468 ms
13,052 KB
testcase_58 AC 233 ms
8,212 KB
testcase_59 AC 544 ms
13,840 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n,m;
  cin>>n>>m;

  vvi e(n, vi());
  rep(i, m){
    int p,q;
    cin>>p>>q;p--;q--;
    e[p].pb(q);
    e[q].pb(p);
  }

  int q;cin>>q;
  rep(i, q){
    int r[n]={};
    int d[n]={};
    rep(i, n) d[i]=-1;
    int st;cin>>st;st--;
    PQ<pii> s;
    s.push(mp(0LL, st));
    for (auto& el:e[st]){
      s.push(mp(1LL, el));
    }
    while(!s.empty()){
      pii node = s.top();s.pop();
      if (r[node.second]==1) continue;

      d[node.second] = node.first;
      r[node.second]=1;
      for (auto& el:e[node.second]){
        s.push(mp(node.first+1, el));
      }
    }
    dump_1d(d, n);
    int f=0;
    rep(i, n){
      if (d[i]>0) f++;
    }
    int res=0;
    res = max(0LL, *max_element(d, d+n));
    rep(j, 20){
      if (pow(2, j)>=res){
        res=j;
        break;
      }
    }
    cout << f << " " << res << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}
0