# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
97330 |
2019-02-15T09:00:36 Z |
luckyboy |
Burza (COCI16_burza) |
C++14 |
|
60 ms |
3584 KB |
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 405
#define maxm 21
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,k,st[maxn],en[maxn],leaf,h[maxn];
bool dp[maxn][1 << maxm];
vector <int> a[maxn],b[maxn];
void Dfs(int u,int par)
{
if (h[u] == k - 1)
{
st[u] = leaf++;
en[u] = leaf;
return;
}
st[u] = leaf;
for (int v : a[u])
if (v != par)
{
h[v] = h[u] + 1;
Dfs(v,u);
}
en[u] = leaf;
}
int main()
{
ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
//freopen(Task".inp", "r",stdin);
//freopens(Task".out", "w",stdout);
cin >> n >> k;
if (k * k >= n) return cout << "DA",0;
FOR(i,1,n-1)
{
int x,y;
cin >> x >> y;
a[x].pb(y);
a[y].pb(x);
}
h[1] = -1;
Dfs(1,0);
FOR(i,2,n) b[st[i]].pb(i);
dp[0][0] = 1;
FOR(i,0,leaf - 1)
FOR(j,0,(1 << k) - 1)
{
if (!dp[i][j]) continue;
for (int v : b[i])
if ((j >> h[v]) & 1);
else
{
dp[en[v]][j + (1 << h[v])] = 1;
}
}
FOR(i,0,(1 << k) - 1)
if (dp[leaf][i])
{
return cout << "DA",0;
}
cout << "NE";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1152 KB |
Output is correct |
2 |
Correct |
39 ms |
2808 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1568 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
3068 KB |
Output is correct |
2 |
Correct |
45 ms |
2852 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
416 KB |
Output is correct |
5 |
Correct |
54 ms |
3192 KB |
Output is correct |
6 |
Correct |
4 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
3100 KB |
Output is correct |
2 |
Correct |
41 ms |
2808 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1664 KB |
Output is correct |
2 |
Correct |
59 ms |
3584 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1152 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
2396 KB |
Output is correct |
2 |
Correct |
54 ms |
3192 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
2972 KB |
Output is correct |
2 |
Correct |
44 ms |
3004 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
3320 KB |
Output is correct |
2 |
Correct |
54 ms |
3056 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
55 ms |
3324 KB |
Output is correct |
6 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1536 KB |
Output is correct |
2 |
Correct |
46 ms |
2980 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1024 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
896 KB |
Output is correct |
2 |
Correct |
58 ms |
3164 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1780 KB |
Output is correct |
2 |
Correct |
57 ms |
3292 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
23 ms |
1912 KB |
Output is correct |
6 |
Correct |
3 ms |
896 KB |
Output is correct |