# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
577961 |
2022-06-15T16:42:40 Z |
Ronin13 |
Burza (COCI16_burza) |
C++14 |
|
783 ms |
524288 KB |
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int NMAX = 401;
const int inf = 1e9 + 1;
vector <vector <int> > g(NMAX);
bool dp[(1 << 20) - 1][NMAX];
int timer = 1;
int l[NMAX], r[NMAX];
int k;
void dfs(int v, int depth, int e = -1){
if(depth == k){
// cout << v << ' ';
l[v] = r[v] = timer;
timer++;
return;
}
for(int to : g[v]){
if(to == e) continue;
dfs(to, depth + 1, v);
l[v] = min(l[v], l[to]);
r[v] = max(r[v], r[to]);
}
}
void DFS(int v, int depth = -1, int e = -1){
if(l[v] == inf) return;
if(depth != -1){
for(int mask = 0; mask < (1 << (k)); mask++){
if(mask & (1 << depth)) continue;
if(dp[mask][l[v] - 1]) dp[mask + (1 << depth)][r[v]] = true;
}}
for(int to : g[v]){
if(to == e) continue;
DFS(to, depth + 1, v);
}
}
int main(){
int n; cin >> n;
cin >> k;
for(int i = 1; i < n; i++){
int u , v; cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
for(int i = 1; i <= n; i++){
l[i] = inf;
r[i] = 0;
}
if(k * k > n){
cout << "DA\n";
}
for(int i = 0; i < (1 << k); i++) dp[i][0] = true;
dfs(1, 0);
/*for(int i = 1; i <= n; i++){
cout << l[i] << ' ' << r[i] << "\n";
}*/
DFS(1);
/*for(int i = 1; i < (1 << k); i++){
for(int j = 0; j < timer; j++){
dp[i][j] ? cout << 1 : cout << 0;
cout << ' ';
}
cout << "\n";
}*/
dp[(1 << k) - 1][timer - 1] ? cout << "DA" : cout << "NE";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
6740 KB |
Output is correct |
2 |
Correct |
257 ms |
51772 KB |
Output is correct |
3 |
Runtime error |
755 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
51748 KB |
Output is correct |
2 |
Correct |
208 ms |
51740 KB |
Output is correct |
3 |
Runtime error |
613 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
210 ms |
51744 KB |
Output is correct |
2 |
Correct |
279 ms |
51756 KB |
Output is correct |
3 |
Runtime error |
783 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
13160 KB |
Output is correct |
2 |
Correct |
271 ms |
51828 KB |
Output is correct |
3 |
Runtime error |
599 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
51744 KB |
Output is correct |
2 |
Correct |
209 ms |
51748 KB |
Output is correct |
3 |
Runtime error |
604 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
210 ms |
51668 KB |
Output is correct |
2 |
Correct |
213 ms |
51816 KB |
Output is correct |
3 |
Runtime error |
642 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
51756 KB |
Output is correct |
2 |
Correct |
195 ms |
51744 KB |
Output is correct |
3 |
Runtime error |
664 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
13140 KB |
Output is correct |
2 |
Correct |
312 ms |
51744 KB |
Output is correct |
3 |
Runtime error |
624 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
6740 KB |
Output is correct |
2 |
Correct |
231 ms |
51748 KB |
Output is correct |
3 |
Runtime error |
755 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
25940 KB |
Output is correct |
2 |
Correct |
208 ms |
51744 KB |
Output is correct |
3 |
Runtime error |
626 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |