답안 #782375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782375 2023-07-13T21:21:01 Z vgoofficial Burza (COCI16_burza) C++14
160 / 160
364 ms 15580 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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 2124 KB Output is correct
2 Correct 364 ms 15580 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 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 353 ms 15468 KB Output is correct
2 Correct 349 ms 15524 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 344 ms 15356 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 15432 KB Output is correct
2 Correct 354 ms 15428 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 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 3964 KB Output is correct
2 Correct 343 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 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 349 ms 15396 KB Output is correct
2 Correct 353 ms 15376 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 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 15412 KB Output is correct
2 Correct 347 ms 15448 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
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 15400 KB Output is correct
2 Correct 354 ms 15360 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 345 ms 15444 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 4060 KB Output is correct
2 Correct 342 ms 15364 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 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 2132 KB Output is correct
2 Correct 347 ms 15504 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
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 7844 KB Output is correct
2 Correct 356 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 147 ms 7764 KB Output is correct
6 Correct 1 ms 340 KB Output is correct