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;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> inline bool chmin(T& a, const T b) {a = min(a, b); return (a == b);}
template <typename T> inline bool chmax(T& a, const T b) {a = max(a, b); return (a == b);}
const int man = (int)(5e5 + 500);
int n, m;
int a[man];
vector <int> vc;
inline void cls() {
vc.clear();
}
void solve() {
cls();
cin >> n >> m;
for (int i = 0; i < (n - 1); ++i) {
int x, y;
cin >> x >> y;
}
for (int i = 0; i < m; ++i) {
cin >> a[i];
}
sort(a, a + m);
for (int i = 0; i < m; ++i) {
if (i == (m - 1)) {
vc.push_back(a[i]);
} else {
int md = (a[i] + a[i + 1]) >> 1;
vc.push_back(md);
if (abs(a[i] - md) == abs(a[i + 1] - md)) {
++i;
}
}
}
cout << (int)(vc.size()) << "\n";
for (auto& i : vc) {
cout << i << " ";
}
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
#ifdef _LOCAL
system("color a");
freopen("in.txt", "r", stdin);
cin >> t;
#endif
for (int i = 1; i <= t; ++i) {
cerr << "Case #" << i << ": \n";
solve();
cerr << "\n";
}
return 0;
}
# | 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... |