# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
674565 | Nicolas125841 | Burza (COCI16_burza) | C++14 | 505 ms | 18412 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define YES "DA"
#define NO "NE"
vector<vector<int>> layers;
vector<int> ways;
unordered_map<int, bitset<400>> coverage;
bitset<400> dfs(vector<vector<int>> &mp, int n, int p, int d, int k){
if(layers.size() == d){
layers.push_back(vector<int>());
ways.push_back(0);
}
if(d == k){
coverage[n] |= 1;
coverage[n] <<= layers[d].size();
}
layers[d].push_back(n);
for(int v : mp[n]){
if(v != p){
bitset<400> res = dfs(mp, v, n, d+1, k);
if(layers.size() > k && d < k)
coverage[n] |= res;
}
}
if(coverage[n] != 0)
ways[d]++;
return coverage[n];
}
int main(){
cin.tie(NULL)->sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<vector<int>> mp(n, vector<int>());
for(int i = 0; i < n-1; i++){
int u, v;
cin >> u >> v;
mp[--u].push_back(--v);
mp[v].push_back(u);
}
dfs(mp, 0, -1, 0, k);
if(layers.size() <= k)
cout << YES << "\n";
else{
unordered_set<bitset<400>> cur, prev = {bitset<400>()};
bool g = false;
for(int i = 1; i <= k; i++){
for(bitset<400> bs : prev){
for(int v : layers[i]){
if(coverage[v] == 0)
continue;
if((coverage[v] & bs) == 0 && cur.size() <= 100100){
cur.insert(coverage[v] | bs);
if((coverage[v] | bs).count() == layers[k].size())
g = true;
}
}
}
swap(cur, prev);
cur.clear();
}
cout << (g ? YES : NO) << "\n";
}
}
컴파일 시 표준 에러 (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... |