結果

問題 No.994 ばらばらコイン
ユーザー kuhakukuhaku
提出日時 2020-02-22 00:17:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,333 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 201,764 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-17 10:48:38
合計ジャッジ時間 4,456 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 66 ms
9,600 KB
testcase_03 AC 69 ms
10,240 KB
testcase_04 AC 71 ms
9,984 KB
testcase_05 AC 36 ms
6,912 KB
testcase_06 AC 74 ms
10,080 KB
testcase_07 AC 75 ms
10,112 KB
testcase_08 AC 51 ms
8,064 KB
testcase_09 AC 70 ms
9,728 KB
testcase_10 AC 51 ms
7,936 KB
testcase_11 AC 58 ms
8,704 KB
testcase_12 AC 59 ms
9,088 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> tree;
Vec depth;

void dfs(ll node, ll d){
	if(depth[node] <= d) return;
	depth[node] = d;
	for(ll i : tree[node]) dfs(i, d+1);
}

int main(void){
	ll n, k;
	cin >> n >> k;
	tree.resize(n);
	depth.assign(n, LINF);
	for(ll i = 0; i < n-1; i++){
		ll a, b;
		cin >> a >> b;
		a--, b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}
	if(n < k) cout << -1 << endl;
	else cout << k-1 << endl;

	return 0;
}
0