# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381380 |
2021-03-25T07:10:57 Z |
NONAME |
Pastiri (COI20_pastiri) |
C++17 |
|
178 ms |
4200 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
93 ms |
492 KB |
Output is correct |
2 |
Correct |
90 ms |
492 KB |
Output is correct |
3 |
Correct |
91 ms |
364 KB |
Output is correct |
4 |
Correct |
178 ms |
4200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |