結果

問題 No.812 Change of Class
ユーザー daleksprinterdaleksprinter
提出日時 2019-04-12 22:44:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 436 ms / 4,000 ms
コード長 3,483 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 176,028 KB
実行使用メモリ 11,316 KB
最終ジャッジ日時 2023-09-03 13:58:58
合計ジャッジ時間 10,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
8,732 KB
testcase_01 AC 12 ms
5,936 KB
testcase_02 AC 32 ms
7,280 KB
testcase_03 AC 65 ms
9,092 KB
testcase_04 AC 59 ms
8,648 KB
testcase_05 AC 403 ms
10,444 KB
testcase_06 AC 436 ms
10,264 KB
testcase_07 AC 6 ms
5,968 KB
testcase_08 AC 5 ms
5,292 KB
testcase_09 AC 310 ms
10,368 KB
testcase_10 AC 322 ms
10,252 KB
testcase_11 AC 17 ms
7,052 KB
testcase_12 AC 160 ms
9,304 KB
testcase_13 AC 4 ms
5,384 KB
testcase_14 AC 3 ms
5,360 KB
testcase_15 AC 202 ms
8,632 KB
testcase_16 AC 15 ms
5,720 KB
testcase_17 AC 183 ms
8,872 KB
testcase_18 AC 131 ms
7,824 KB
testcase_19 AC 157 ms
8,396 KB
testcase_20 AC 398 ms
9,996 KB
testcase_21 AC 131 ms
7,844 KB
testcase_22 AC 55 ms
6,760 KB
testcase_23 AC 12 ms
5,720 KB
testcase_24 AC 17 ms
5,892 KB
testcase_25 AC 44 ms
6,628 KB
testcase_26 AC 261 ms
9,600 KB
testcase_27 AC 232 ms
8,912 KB
testcase_28 AC 154 ms
8,340 KB
testcase_29 AC 35 ms
6,128 KB
testcase_30 AC 209 ms
8,828 KB
testcase_31 AC 170 ms
8,424 KB
testcase_32 AC 70 ms
6,804 KB
testcase_33 AC 214 ms
9,240 KB
testcase_34 AC 16 ms
5,668 KB
testcase_35 AC 23 ms
6,256 KB
testcase_36 AC 11 ms
5,696 KB
testcase_37 AC 51 ms
7,004 KB
testcase_38 AC 8 ms
6,220 KB
testcase_39 AC 54 ms
7,068 KB
testcase_40 AC 16 ms
5,984 KB
testcase_41 AC 8 ms
6,044 KB
testcase_42 AC 112 ms
8,352 KB
testcase_43 AC 26 ms
7,264 KB
testcase_44 AC 75 ms
7,536 KB
testcase_45 AC 10 ms
5,620 KB
testcase_46 AC 24 ms
7,276 KB
testcase_47 AC 74 ms
7,532 KB
testcase_48 AC 87 ms
7,828 KB
testcase_49 AC 23 ms
6,300 KB
testcase_50 AC 4 ms
5,412 KB
testcase_51 AC 25 ms
6,360 KB
testcase_52 AC 51 ms
7,528 KB
testcase_53 AC 15 ms
5,864 KB
testcase_54 AC 13 ms
5,924 KB
testcase_55 AC 55 ms
9,588 KB
testcase_56 AC 65 ms
10,360 KB
testcase_57 AC 70 ms
10,632 KB
testcase_58 AC 37 ms
8,368 KB
testcase_59 AC 82 ms
11,316 KB
testcase_60 AC 4 ms
5,356 KB
testcase_61 AC 3 ms
5,452 KB
testcase_62 AC 3 ms
5,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, m;
vec<vec<int>> edges(101010);
void in(){
    cin >> n >> m;
    rep(i,0,m){
        int f, t;
        cin >> f >> t;
        f--; t--;
        edges[f].push_back(t);
        edges[t].push_back(f);
    }
}

void solve(){


    int q; cin >> q;
    rep(i,0,q){
        int s = input(); s--;
        vi dist(n, inf);
        queue<pi> que;
        que.push(pi(s, 0));

        while(not que.empty()){

            int v = que.front().first;
            int d = que.front().second;
            que.pop();

            chmin(dist[v], d);

            rep(i,0,sz(edges[v])){
                int nxt = edges[v][i];
                if(dist[nxt] > d + 1){
                    que.push(pi(nxt, d + 1));
                }
            }
        }

        int cnt = 0;
        int mxdist = 0;
        rep(i,0,n){
            if(dist[i] != inf){
                cnt++;
                chmax(mxdist, dist[i]);
            }
        }

        int day = 0;
        rep(i,0,30){
            if(mxdist & (1 << i)) day = i;
        }
        if(mxdist - (1 << day) > 0) day++;
        cout << cnt - 1 << ' ' << day << endl;


    }

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}
0