| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 727461 | YugiHacker | Burza (COCI16_burza) | C++17 | 53 ms | 3308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
www.youtube.com/YugiHackerChannel
oj.vnoi.info/user/YugiHackerKhongCopCode
*/
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 402
#define bit(mask,i) ((mask>>i)&1)
using namespace std;
int n, k, d[maxn], cnt, in[maxn], out[maxn];
bool f[maxn][1 << 20];
vector <int> h[maxn];
vector <int> a[maxn];
void dfs(int u, int p = -1)
{
if (d[u] == k)
{
in[u] = cnt;
out[u] = ++cnt;
return;
}
in[u] = cnt;
for (int v:a[u]) if (v!=p)
{
d[v] = d[u] + 1;
dfs(v, u);
}
out[u] = cnt;
}
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
if (k * k >= n) return cout << "DA", 0;
f1 (i, n-1)
{
int u, v; cin >> u >> v;
a[u].push_back(v);
a[v].push_back(u);
}
memset(d, -1, sizeof d);
d[1] = 0;
dfs(1);
for (int i=2; i<=n; i++) if(out[i]) h[in[i]].push_back(i);
f[0][0] = 1;
for (int i=0; i<cnt; ++i)
{
f0 (mask, 1 << k)
{
if (f[i][mask])
{
for (int u:h[i])
if (!bit(mask, d[u] - 1))
f[out[u]][mask ^ (1 << d[u] - 1)] = 1;
}
}
}
f0 (mask, 1 << k) if (f[cnt][mask]) return cout << "DA", 0;
cout << "NE";
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
