# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003941 | vjudge1 | Pastiri (COI20_pastiri) | C++17 | 260 ms | 34248 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;
const int MAXN = 500010;
vector <int> v[MAXN];
int ovelha[MAXN], divi[MAXN];
int main(){
int n, k;
cin >> n >> k;
for(int i=1; i<n; i++){
int a, b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=0; i<k; i++){
int a;
cin >> a;
ovelha[i] = a;
}
sort(ovelha, ovelha+k);
int resp = 0;
vector <int> pastor;
for(int i=0; i<k-1; i++){
if(divi[i]==1) continue;
resp++;
if((ovelha[i+1] - ovelha[i])%2 == 0){
divi[i+1] = 1;
pastor.push_back((ovelha[i+1] - ovelha[i])/2 + ovelha[i]);
}
else{
pastor.push_back(ovelha[i]);
}
}
if(divi[k-1]==0){
resp++;
pastor.push_back(ovelha[k-1]);
}
cout << resp << endl;
for(int i=0; i<pastor.size(); i++) cout << pastor[i] << " ";
}
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... |