# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166813 |
2019-12-04T07:35:47 Z |
Atill83 |
Burza (COCI16_burza) |
C++14 |
|
1000 ms |
764 KB |
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 4e2+5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
vector<int> adj[MAXN];
ll d[MAXN][MAXN];
bool did[MAXN][MAXN];
int dep[MAXN];
priority_queue<int> q;
void dfs(int a, int par){
dep[a]++;
for(int i: adj[a]){
if(i != par){
dfs(i, a);
dep[a] += dep[i];
}
}
}
int dp(int a, int g, int par){
if(did[a][g]) return d[a][g];
did[a][g] = 1;
if(a != 1 && adj[a].size() == 1){
return d[a][g] = 1;
}else{
d[a][g] = INF;
int many = min(g, (a == 1 ? (int)adj[a].size() : (int)adj[a].size() - 1));
for(int i = 0; i <= many; i++){
for(int j = 0; j < (int)adj[a].size(); j++){
int cur = adj[a][j];
if(cur == par) continue;
q.push(dp(cur, g - i + 1, a));
}
for(int j = 0; j < i; j++){
q.pop();
}
if(q.empty()){
d[a][g] = 1;
}else{
d[a][g] = min(d[a][g], (ll)q.top() + 1);
}
while(!q.empty()) q.pop();
}
return d[a][g];
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("../IO/int.txt","r",stdin);
freopen("../IO/out.txt","w",stdout);
#endif
cin>>n>>k;
for(int i = 0; i < n - 1; i++){
int a, b;
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
//cout<<dp(1, 1, -1)<<endl;
cout<<((dp(1, 1, -1) <= k) ? "DA" : "NE")<<endl;
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
556 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |