# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244668 | kimbj0709 | Railway (BOI17_railway) | C++14 | 381 ms | 2432 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 10050
vector<int> cnt(maxn,0);
vector<int> childcnt(maxn,0);
vector<int> curr(maxn,0);
vector<vector<pair<int,int> > > adj(maxn);
void dfs(int node,int parent){
for(auto k:adj[node]){
if(k.first!=parent){
dfs(k.first,node);
if(childcnt[k.first]>=1){
cnt[k.second]++;
}
childcnt[node] += childcnt[k.first];
}
}
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int no_of_vertex,no_of_people,mini;
int no_of_input;
int input1,input2,input3,input;
cin >> no_of_vertex >> no_of_people >> mini;
for(int i=0;i<no_of_vertex-1;i++){
cin >> input1 >> input2;
adj[input1].push_back({input2,i});
adj[input2].push_back({input1,i});
}
for(int i=0;i<no_of_people;i++){
cin >> no_of_input;
for(int j=0;j<no_of_input;j++){
cin >> input;
childcnt[input] = 1;
}
dfs(input,-1);
for(int j=0;j<=no_of_vertex;j++){
childcnt[j] = 0;
}
/*for(int j=0;j<=no_of_vertex;j++){
cout << cnt[j] << " ";
}
cout << "\n";*/
}
vector<int> ans;
for(int i=0;i<cnt.size();i++){
if(cnt[i]>=mini){
ans.push_back(i);
}
}
cout << ans.size() << "\n";
for(auto k:ans){
cout << k+1 << " ";
}
}
Compilation message (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... |