結果

問題 No.812 Change of Class
ユーザー oxyshoweroxyshower
提出日時 2020-01-15 13:49:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,291 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 177,496 KB
実行使用メモリ 20,384 KB
最終ジャッジ日時 2023-09-03 16:02:47
合計ジャッジ時間 22,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 11 ms
5,192 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 97 ms
10,128 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 33 ms
6,168 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 23 ms
5,356 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 387 ms
14,648 KB
testcase_56 AC 508 ms
17,864 KB
testcase_57 AC 535 ms
18,440 KB
testcase_58 AC 270 ms
11,200 KB
testcase_59 AC 563 ms
20,384 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 2 ms
4,376 KB
testcase_62 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

struct edge{ int to,cost; };
vector<int> dikstra(int s,vector<vector<edge>> G){
  typedef pair<int, int> P;
  const int INF = 1LL << 60;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(G.size(),INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  return d;
}

signed main(){

  int n, m; cin >> n >> m;
  vector<vector<edge>> G(n);
  for(int i = 0; i < m; i++){
    int s, t; cin >> s >> t;
    s--, t--;
    G[s].push_back({t, 1});
    G[t].push_back({s, 1});
  }

  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int s; cin >> s;
    s--;
    auto dp = dikstra(s, G);
    int friends = 0, date = 0;
    for(int i = 0; i < n; i++){
      if(i != s && dp[i] != INF){
        friends++;
        date = max(date, dp[i]);
      }
    }
    if(date == 1) date--;
    cout << friends << " " << (date+1)/2 << endl;
  }

  return 0;
}
0