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 lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
//#define int long long int
#define N 500005
int main(){
lalala;
int n,k;cin>>n>>k;
for(int i=0;i<n-1;i++){int a,b;cin>>a>>b;}
int koyun[k],kacak[k];
for(int i=0;i<k;i++){
cin>>koyun[i];
kacak[i]=0;
}
sort(koyun,koyun+k);
vector<int> simyaci;
for(int i=0;i<k-1;i++){
if((koyun[i+1]-koyun[i])%2==0){
simyaci.push_back((koyun[i]+koyun[i+1])/2);
kacak[i]=kacak[i+1]=1;
i++;
}
}
for(int i=0;i<k;i++){
if(kacak[i])continue;
simyaci.push_back(koyun[i]);
}
cout<<simyaci.size()<<endl;
for(auto u:simyaci)cout<<u<<" ";
cout<<endl;
}
# | 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... |