| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1117374 | vux2code | Burza (COCI16_burza) | C++17 | 40 ms | 3336 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.
// Src : Vux2Code
/* Note :
*/
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
// template <typename T> void vout(T s){ cout << s << endl; exit(0);}
typedef int ll;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll maxN = 4e2 + 5, maxLog = 20;
void maximize (ll &x, ll y) {x = max (x, y);}
void minimize (ll &x, ll y) {x = min (x, y);}
/* ---------HASHING-------- */
// const base = 31, mod2 = 1e9 + 9;
/* ---------BITMASK-------- */
// ll count (ll x) {return __builtin_popcountll (x);}
// ll fst (ll x) {return 63 - __builtin_clzll (x);}
// ll last (ll x) {return __builtin_ctzll (x);}
bool bit (ll x, ll y) {return ((x >> y) & 1);}
ll t = 1;
ll n, k, h [maxN], st [maxN], en [maxN], cnt;
vector <ll> ke [maxN], hvec [maxN];
bool f [maxN] [1 << maxLog];
void dfs (ll x, ll pr) {
if (x) h [x] = h [pr] + 1;
if (h [x] == k - 1) {
st [x] = cnt ++;
en [x] = cnt;
return;
}
st [x] = cnt;
for (ll i : ke [x]) if (i != pr) {
dfs (i, x);
}
en [x] = cnt;
}
bool solve () {
cin >> n >> k;
if (k * k >= n) return true;
for (int i = 1, u, v; i < n; i ++) {
cin >> u >> v;
u --; v --;
ke [u]. push_back (v);
ke [v]. push_back (u);
}
h [0] = -1;
dfs (0, -1);
for (int i = 1; i < n; i ++) hvec [st [i]]. push_back (i);
f [0] [0] = 1;
for (int i = 0; i < cnt; i ++) {
for (int mask = 0; mask < (1 << k); mask ++) {
if (!f [i] [mask]) continue;
for (ll j : hvec [i]) {
if (bit (mask, h [j])) continue;
f [en [j]] [mask | 1 << h [j]] = 1;
}
}
}
for (int i = 0; i < (1 << k); i ++) if (f [cnt] [i]) return true;
return false;
}
int main () {
ios::sync_with_stdio (0);
cin. tie (0);
cout. tie (0);
#define TASK "task"
if (fopen (TASK".inp", "r")) {
freopen (TASK".inp", "r", stdin);
freopen (TASK".out", "w", stdout);
}
// cin >> t;
while (t --) cout << (solve () ? "DA" : "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... | ||||
