# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
960773 |
2024-04-11T03:24:40 Z |
doducanh |
Burza (COCI16_burza) |
C++14 |
|
35 ms |
952 KB |
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int max_cover[(1<<20)+7];
vector<int>a[405];
vector<int>dep[405];
vector<vector<int>>cutoff;
vector<pair<int,int>>interval;
map<int,int>lost;
int n,k;
void process(int at,int prev,int depth)
{
dep[depth].push_back(at);
if(depth==k){
lost[at]=lost.size();
cutoff[at]={at};
return;
}
for(int v:a[at])if(v!=prev){
process(v,at,depth+1);
cutoff[at].insert(cutoff[at].end(),cutoff[v].begin(),cutoff[v].end());
}
}
main()
{
cin>>n>>k;
cutoff.resize(n+1);
for(int i=1;i<=n-1;i++){
int x,y;
cin>>x>>y;
x--,y--;
a[x].push_back(y);
a[y].push_back(x);
}
if(k*k>=n){
cout<<"DA";
return 0;
}
process(0,0,0);
for(const vector<int>&cc:cutoff){
if(cc.empty()){
interval.push_back({-1,-1});
}
else interval.push_back({lost[cc.front()]+1,lost[cc.back()]+1});
}
max_cover[0]=0;
for(int mask=1;mask<(1<<k);mask++){
int &curr=max_cover[mask];
for(int to_add=0;to_add<k;to_add++){
if((mask>>to_add)&1){
int prev=max_cover[mask&(1<<to_add)];
for(int v:dep[to_add+1]){
if(prev+1>=interval[v].fi){
curr=max(curr,interval[v].se);
}
}
}
}
if(curr==lost.size()){
cout<<"DA";
return 0;
}
}
cout<<"NE";
}
Compilation message
burza.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
25 | main()
| ^~~~
burza.cpp: In function 'int main()':
burza.cpp:60:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | if(curr==lost.size()){
| ~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
852 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
860 KB |
Output is correct |
2 |
Correct |
29 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
32 ms |
888 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
860 KB |
Output is correct |
2 |
Correct |
29 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
604 KB |
Output is correct |
2 |
Correct |
30 ms |
880 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
860 KB |
Output is correct |
2 |
Correct |
30 ms |
852 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
864 KB |
Output is correct |
2 |
Correct |
35 ms |
812 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
904 KB |
Output is correct |
2 |
Correct |
29 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
30 ms |
804 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
756 KB |
Output is correct |
2 |
Correct |
31 ms |
952 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
600 KB |
Output is correct |
2 |
Correct |
32 ms |
928 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
13 ms |
628 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |