Submission #631585

#TimeUsernameProblemLanguageResultExecution timeMemory
631585berrBurza (COCI16_burza)C++17
0 / 160
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj[500]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin>>n>>k; for(int i=0; i<n-1; i++) { int x, y; cin>>x>>y; adj[x].push_back(y); adj[y].push_back(x); } vector<int> vis(n+1); priority_queue<array<int, 2>> q; q.push({1, 1}); int t=0; vis[1]=1; while(q.size()) { priority_queue<array<int, 2>> q2; vis[q.top()[1]]=1; if(q.top()[1]!=1) cout<<q.top()[1]; q.pop(); while(q.size()) { vis[q.top()[1]]=1; for(auto i: adj[q.top()[1]]) { if(!vis[i]) q2.push({(int)(adj[i].size()-1), i}); } q.pop(); } q=q2; t++; } if(t<k) cout<<"DA"; else cout<<"NE"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...