結果

問題 No.994 ばらばらコイン
ユーザー iqueue02
提出日時 2020-02-21 21:58:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 1,987 ms
コンパイル使用メモリ 170,008 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-10-08 21:41:43
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n, k;
  cin >> n >> k;
  vector<vector<int>> g(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  if (n < k) {
    cout << -1 << endl;
    return 0;
  } 
  cout << k - 1 << endl;
  return 0;
}
0