Submission #821280

# Submission time Handle Problem Language Result Execution time Memory
821280 2023-08-11T08:39:29 Z Jan636 Burza (COCI16_burza) C++14
160 / 160
390 ms 15588 KB
//Some wierd BFS can also pass(?)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define siz(x) (int)x.size()
#define pb push_back
#define all(x) x.begin(), x.end()
//===========================================
const int MAX = 405;
vi adj[MAX];
int p[MAX], dep[MAX], depb[MAX];
set<vi> vis;

void dfs(int v){
    for (int u: adj[v]){
        if (u == p[v]) continue;
        p[u] = v;
        dep[u] = dep[v]+1;
        dfs(u);
        depb[v] = max(depb[v], depb[u]+1);
    }
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n, k; cin >> n >> k;
    for (int i = 1; i < n; i++){
        int a, b; cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1);
    queue<vi> q; q.push({1});
    while (siz(q)){
        auto vec = q.front(); q.pop();
        if (vec.empty()){
            cout << "DA\n";
            return 0;
        }
        int rem = k-dep[vec[0]];
        vi vv;
        for (int v: vec){
            for (int u: adj[v]){
                if (u == p[v]) continue;
                if (depb[u]+1 >= rem) vv.pb(u);
            }
        }
        if (siz(vv) > rem) continue;
        for (int i = 0; i < siz(vv); i++){
            swap(vv[i], vv.back());
            vector<int> temp = vv; temp.pop_back(); sort(all(temp));
            if (!vis.count(temp)){
                q.push(temp);
                vis.insert(temp);
            }
            swap(vv[i], vv.back());
        }
    }
    cout << "NE\n";
}
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2148 KB Output is correct
2 Correct 378 ms 15380 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 348 ms 15352 KB Output is correct
2 Correct 360 ms 15448 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 349 ms 15468 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 15468 KB Output is correct
2 Correct 352 ms 15384 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 4032 KB Output is correct
2 Correct 380 ms 15436 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 359 ms 15356 KB Output is correct
2 Correct 379 ms 15568 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 15416 KB Output is correct
2 Correct 349 ms 15588 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 15404 KB Output is correct
2 Correct 354 ms 15396 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 348 ms 15472 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 3964 KB Output is correct
2 Correct 390 ms 15392 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2184 KB Output is correct
2 Correct 374 ms 15468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 7924 KB Output is correct
2 Correct 365 ms 15468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 152 ms 7780 KB Output is correct
6 Correct 0 ms 340 KB Output is correct