# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
400023 |
2021-05-07T07:04:42 Z |
Radman_ |
Burza (COCI16_burza) |
C++14 |
|
61 ms |
6220 KB |
// //
// Radmanシ //
// //
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
#define F first
#define S second
const int maxn=400+5,inf=1e9;
int dp[maxn][1<<20],mark[maxn],power[1<<21],p[21][maxn],s[maxn],e[maxn];
vector<int> yal[maxn];
vector<pii> a[maxn];
int n,k,t=0;
pii dfs(int now,int d)
{
mark[now]=1;
if(d==k)
{
t++;
//a[k].push_back(pii(t,t));
return pii(t,t);
}
p[d][now]=now;
for(int i=d-2;i>=0;i--)
p[i][now]=p[i][p[d-1][now]];
for(int i=d+1;i<=20;i++)
p[i][now]=-1;
int l=inf,r=0;
int sizeee=yal[now].size();
for(int i=0;i<sizeee;i++)
{
int next=yal[now][i];
if(mark[next])
continue;
p[d][next]=now;
pii p=dfs(next,d+1);
l=min(l,p.F);
r=max(r,p.S);
}
if(pii(l,r)!=pii(inf,0))
{
s[now]=l;
e[now]=r;
//a[d].push_back(pii(l,r));
}
return pii(l,r);
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>k;
for(int i=1;i<n;i++)
{
int u,v;
cin>>u>>v;
yal[u].push_back(v);
yal[v].push_back(u);
}
if(k*k>=n)
{
cout<<"DA"<<endl;
return 0;
}
int pow=1;
power[1]=0;
for(int i=1;i<=20;i++)
{
pow*=2;
power[pow]=i;
}
dfs(1,0);
for(int mask=0;mask<(1<<k);mask++)
dp[0][mask]=1;
for(int i=1;i<=t;i++)
{
//cout<<i<<endl;
for(int mask=1;mask<(1<<k);mask++)
{
//cout<<mask<<endl;
int mask2=mask;
int last=(mask&(-mask));
int hi=power[last];
if(!hi)
{
mask2>>=1;
last=(mask2&(-mask2));
hi=power[last];
hi++;
}
int pa=p[hi][i];
//cout<<i<<' '<<mask<<' '<<last<<' '<<hi<<' '<<pa<<endl;
if(pa==-1)
continue;
if(dp[s[pa]-1][mask-(1<<hi)])
dp[i][mask]=1;
//cout<<dp[i][mask]<<endl;
}
}
int f=0;
for(int mask=1;mask<(1<<k);mask++)
{
if(!dp[t][mask])
continue;
f=1;
break;
}
if(f)
cout<<"DA"<<endl;
else
cout<<"NE"<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
4656 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
4676 KB |
Output is correct |
2 |
Correct |
52 ms |
5228 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1180 KB |
Output is correct |
2 |
Correct |
61 ms |
2672 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
1 ms |
720 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
4192 KB |
Output is correct |
2 |
Incorrect |
51 ms |
6220 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
2128 KB |
Output is correct |
2 |
Incorrect |
56 ms |
2620 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
2112 KB |
Output is correct |
2 |
Correct |
51 ms |
3676 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
46 ms |
3680 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1020 KB |
Output is correct |
2 |
Correct |
56 ms |
3652 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
1 ms |
716 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
576 KB |
Output is correct |
2 |
Correct |
56 ms |
3656 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1904 KB |
Output is correct |
2 |
Correct |
57 ms |
3144 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
22 ms |
2892 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |