# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381347 |
2021-03-25T06:42:00 Z |
NONAME |
Pastiri (COI20_pastiri) |
C++17 |
|
189 ms |
12776 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;
}
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 |
88 ms |
364 KB |
Output is correct |
2 |
Correct |
91 ms |
408 KB |
Output is correct |
3 |
Correct |
106 ms |
7064 KB |
Output is correct |
4 |
Correct |
189 ms |
12776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
Sheep 857 not protected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Sheep 188 not protected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
104 ms |
492 KB |
Sheep 54 not protected |
2 |
Halted |
0 ms |
0 KB |
- |