Task: | Creating Offices |
Sender: | aalto2024m_002 |
Submission time: | 2024-11-25 20:29:48 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | WRONG ANSWER | 0.01 s | details |
#5 | WRONG ANSWER | 0.01 s | details |
#6 | ACCEPTED | 0.16 s | details |
#7 | ACCEPTED | 0.11 s | details |
#8 | WRONG ANSWER | 0.14 s | details |
#9 | WRONG ANSWER | 0.18 s | details |
#10 | WRONG ANSWER | 0.14 s | details |
#11 | ACCEPTED | 0.15 s | details |
#12 | ACCEPTED | 0.09 s | details |
#13 | ACCEPTED | 0.13 s | details |
#14 | WRONG ANSWER | 0.14 s | details |
#15 | WRONG ANSWER | 0.14 s | details |
#16 | ACCEPTED | 0.07 s | details |
#17 | WRONG ANSWER | 0.10 s | details |
#18 | WRONG ANSWER | 0.01 s | details |
#19 | ACCEPTED | 0.08 s | details |
#20 | WRONG ANSWER | 0.10 s | details |
#21 | WRONG ANSWER | 0.01 s | details |
#22 | WRONG ANSWER | 0.10 s | details |
Code
#ifdef ONPC #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #define char unsigned char #define rep(i, a, b) for(int i=a; i< (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define LSOne(S) ((S) & -(S)) using namespace std; // mt19937 rnd(239); mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> int sgn(T x) { return (T(0) < x) - (x < T(0)); } typedef long double T; typedef complex<T> pt; #define X real() #define Y imag() template<class T> istream& operator>> (istream& is, complex<T>& p) { T value; is >> value; p.real(value); is >> value; p.imag(value); return is; } typedef long long ll; typedef long double ld; using pi = pair<ll, ll>; using vi = vector<ll>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int popcnt(int x) { return __builtin_popcount(x); } int popcnt(ll x) { return __builtin_popcountll(x); } #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define dbg(x...) #endif template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;} template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;} const int INF = 1e9; // 10^9 = 1B is < 2^31-1 const ll LLINF = 4e18; // 4*10^18 is < 2^63-1 const double EPS = 1e-9; const ll MOD = 1e9+7; const int N=2e5+10; vector<int> adj[N]; ll dp[N]; vector<int> poss; int d; void dfs(int node, int prev, int dist) { if(dist>=d) { poss.pb(node); dist=0; } for(auto &w:adj[node]) { if(w==prev) continue; dfs(w, node, dist+1); } } int solve() { int n; std::cin >> n >> d; for (int i = 0; i < n-1; i++) { int a,b; std::cin >> a >> b; adj[a].pb(b); adj[b].pb(a); } for (int i = 1; i <= n; i++) { if(adj[i].size()==1) { poss.pb(i); dfs(i, -1, 0); break; } } std::cout << poss.size() << std::endl; for(auto &w:poss) { std::cout << w << " "; } std::cout << std::endl; //__print(poss); std::cout << std::endl; return 0; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int TET = 1; //cin >> TET; for (int i = 1; i <= TET; i++) { #ifdef ONPC cout << "TEST CASE#" << i << endl; #endif if (solve()) { break; } #ifdef ONPC cout << "__________________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10 3 5 10 8 7 1 4 3 5 ... |
correct output |
---|
4 1 3 8 9 |
user output |
---|
4 8 1 3 9 |
Test 2
Verdict: ACCEPTED
input |
---|
10 5 8 7 8 2 8 5 8 3 ... |
correct output |
---|
1 10 |
user output |
---|
1 1 |
Test 3
Verdict: ACCEPTED
input |
---|
10 5 3 7 7 10 7 8 9 1 ... |
correct output |
---|
2 1 4 |
user output |
---|
2 1 4 |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 4 8 5 8 6 1 8 4 9 ... |
correct output |
---|
3 3 9 10 |
user output |
---|
4 2 5 6 4 |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 3 7 8 1 10 4 3 1 5 ... |
correct output |
---|
4 3 8 9 10 |
user output |
---|
4 3 10 5 7 |
Test 6
Verdict: ACCEPTED
input |
---|
200000 9 7112 139320 131799 678 101561 62983 190924 56029 ... |
correct output |
---|
22223 7 27 28 29 34 35 53 63 65 71 7... |
user output |
---|
22223 104543 173442 43755 139047 900... Truncated |
Test 7
Verdict: ACCEPTED
input |
---|
200000 1 117863 108209 117863 142206 117863 98558 117863 124329 ... |
correct output |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
200000 1 117863 108209 142206 98558 1... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
200000 2 196127 1313 59937 27170 188592 185528 106118 64586 ... |
correct output |
---|
119174 1 2 7 8 9 10 11 14 16 17 18 19... |
user output |
---|
100123 1 125432 106982 78631 188095 1... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
200000 3 174335 181372 73884 35338 65409 30522 120927 7911 ... |
correct output |
---|
66675 10 30 31 39 42 46 48 52 54 55 ... |
user output |
---|
66667 469 125343 170618 125294 17683... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
200000 9 156193 90960 92081 42156 64080 41287 65601 109953 ... |
correct output |
---|
22257 8 14 30 42 59 62 74 82 99 103 ... |
user output |
---|
22221 490 92332 101647 84275 68046 1... Truncated |
Test 11
Verdict: ACCEPTED
input |
---|
200000 200000 183551 137559 138103 16820 21892 134252 182028 187950 ... |
correct output |
---|
1 40760 |
user output |
---|
1 40760 |
Test 12
Verdict: ACCEPTED
input |
---|
200000 459 30507 105253 30507 95541 30507 161230 30507 135274 ... |
correct output |
---|
1 200000 |
user output |
---|
1 1 |
Test 13
Verdict: ACCEPTED
input |
---|
200000 327 43832 190820 78666 45374 184224 57261 193962 158173 ... |
correct output |
---|
1 181355 |
user output |
---|
1 5 |
Test 14
Verdict: WRONG ANSWER
input |
---|
200000 217 31004 146202 108924 82624 43788 48134 199877 157947 ... |
correct output |
---|
924 279 304 418 471 539 566 713 10... |
user output |
---|
915 304 29364 51445 85852 40922 14... Truncated |
Test 15
Verdict: WRONG ANSWER
input |
---|
200000 475 77454 87171 23492 138432 137402 34171 181862 18661 ... |
correct output |
---|
394 833 915 982 2281 2467 2531 267... |
user output |
---|
414 658 143774 38258 93526 198346 ... Truncated |
Test 16
Verdict: ACCEPTED
input |
---|
199999 4 1 2 2 3 1 4 4 5 ... |
correct output |
---|
99999 3 5 7 9 11 13 15 17 19 21 23 2... |
user output |
---|
99999 3 5 7 9 11 13 15 17 19 21 23 2... Truncated |
Test 17
Verdict: WRONG ANSWER
input |
---|
199397 946 29518 79973 29518 71183 71183 194147 29518 156561 ... |
correct output |
---|
159 52 101 164 243 252 621 1256 37... |
user output |
---|
267 52 106223 195032 108122 72593 ... Truncated |
Test 18
Verdict: WRONG ANSWER
input |
---|
5 3 1 2 2 3 3 4 3 5 |
correct output |
---|
2 1 5 |
user output |
---|
3 1 4 5 |
Test 19
Verdict: ACCEPTED
input |
---|
199397 5000 1 2 2 3 3 4 4 5 ... |
correct output |
---|
40 4397 9397 14397 19397 24397 29... |
user output |
---|
40 1 5001 10001 15001 20001 25001... Truncated |
Test 20
Verdict: WRONG ANSWER
input |
---|
199397 945 29518 79973 29518 71183 71183 194147 29518 156561 ... |
correct output |
---|
160 52 101 164 243 252 621 1256 37... |
user output |
---|
268 52 57445 160880 80367 44874 27... Truncated |
Test 21
Verdict: WRONG ANSWER
input |
---|
1 1 |
correct output |
---|
1 1 |
user output |
---|
0 |
Test 22
Verdict: WRONG ANSWER
input |
---|
199397 899 29518 79973 29518 71183 71183 194147 29518 156561 ... |
correct output |
---|
183 52 101 164 243 252 621 792 125... |
user output |
---|
314 52 88029 22046 50222 21567 915... Truncated |