Submission #381380

#TimeUsernameProblemLanguageResultExecution timeMemory
381380NONAMEPastiri (COI20_pastiri)C++17
8 / 100
178 ms4200 KiB
#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; assert(abs(x - y) == 1); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...