# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
441715 | Deepesson | Burza (COCI16_burza) | C++17 | 3 ms | 716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAX 405
std::vector<int> con[MAX],org[MAX];
bool existe[MAX][MAX];
short tab[MAX][MAX];
short dp(int pos,int movs) {
if(existe[pos][movs])return tab[pos][movs];
existe[pos][movs]=true;
short best=1000;
for(int i=0;i!=movs+1;++i){
std::vector<short> resps;
for(auto&x:con[pos]){
resps.push_back(1+dp(x,movs+1-i));
}
std::sort(resps.begin(),resps.end(),std::greater<short>());
if(i>=con[pos].size()){
best=0;
}else best=std::min(best,resps[i]);
}
return tab[pos][movs]=best;
}
int main()
{
int N,K;
std::cin>>N>>K;
for(int i=1;i!=N;++i){
int a,b;
std::cin>>a>>b;--a;--b;
org[a].push_back(b);
org[b].push_back(a);
}
typedef std::pair<int,int> pii;
std::queue<pii> queue;
queue.push({0,-1});
bool visitou[MAX]={};
while(queue.size()){
auto _ = queue.front();
queue.pop();
if(visitou[_.first])continue;
visitou[_.first]=true;
if(_.second!=-1){
con[_.second].push_back(_.first);
}
for(auto&x:org[_.first])
queue.push({x,_.first});
}
int r=dp(0,1);
if(r<K){
printf("DA\n");
}else printf("NE\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... |