Submission #102317

# Submission time Handle Problem Language Result Execution time Memory
102317 2019-03-24T10:03:09 Z SirCeness Burza (COCI16_burza) C++14
0 / 160
3 ms 384 KB
#include <bits/stdc++.h>

#define mod 1000000007

typedef long long ll;

using namespace std;

int n, m;
list<int> adj[400];
multiset<int> sets[400];

int f(int ata, int node){
	//cout << "f(" << ata << ", " << node << ")\n";
	for (list<int>::iterator it = adj[node].begin(); it != adj[node].end(); ++it){
		if ((*it) == ata) continue;
		sets[node].insert(f(node, *it));
	}
	if (sets[node].size() < 2) return 0;
	multiset<int>::iterator it = sets[node].end();
	advance(it, -2);
	return 1+(*it);
}

int main(){
	//freopen("baskent.gir", "r", stdin);
	
	cin >> n >> m;
	for (int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	int ans = f(-1, 0);
	if (ans < m) cout << "DA" << endl;
	else cout << "NE" << endl;
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -