QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202464 | #6745. Delete the Tree | real_sigma_team# | WA | 1ms | 3788kb | C++23 | 1.6kb | 2023-10-06 04:28:14 | 2023-10-06 04:28:14 |
Judging History
answer
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<vector<bool>> adj(n, vector<bool>(n));
for (int i = 0; i < n - 1; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
adj[u][v] = adj[v][u] = 1;
}
vector<vector<int>> ans;
vector<bool> del(n);
for (int i = 0; i < 10; ++i) {
ans.push_back({});
vector<int> vert(n);
iota(all(vert), 0);
shuffle(all(vert), rnd);
vector<bool> used = del;
for (auto j : vert) {
if (!used[j]) {
ans.back().push_back(j);
used[j] = 1;
vector<int> neighb;
for (int k = 0; k < n; ++k) {
if (!del[k] && adj[j][k]) neighb.push_back(k);
}
for (auto x : neighb) {
used[x] = 1;
for (auto y : neighb) {
if (x != y) adj[x][y] = 1;
}
}
}
}
for (auto j : ans.back()) del[j] = 1;
}
while (ans.back().empty()) ans.pop_back();
cout << ans.size() << '\n';
for (auto i : ans) {
cout << i.size();
for (auto j : i) cout << ' ' << j + 1;
cout << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3724kb
input:
5 1 2 1 3 1 4 4 5
output:
3 3 2 5 3 1 1 1 4
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
500 183 443 32 443 334 443 254 443 331 443 348 443 54 443 430 443 275 443 410 443 360 443 443 468 140 443 179 443 93 443 327 443 128 443 365 443 122 443 43 443 46 443 399 443 398 443 269 443 130 443 227 443 412 443 61 443 295 443 98 443 30 443 197 443 397 443 95 443 192 443 266 443 48 443 310 443 28...
output:
2 499 75 99 290 128 399 426 243 198 165 104 170 206 462 47 5 173 82 312 379 330 496 481 35 161 24 18 8 256 103 320 435 282 471 300 400 30 208 89 269 480 317 284 288 37 460 337 3 53 285 310 372 370 22 102 411 450 446 332 212 264 397 253 191 25 319 449 479 306 476 250 93 43 494 424 453 350 373 132 458...
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
500 80 180 80 254 1 180 80 337 180 323 80 248 180 205 80 189 180 480 80 330 180 454 80 498 142 180 80 193 180 346 80 89 180 389 80 125 180 232 80 93 180 228 80 327 180 357 80 417 180 362 80 278 180 316 80 312 163 180 80 310 176 180 80 463 180 210 80 478 180 294 80 185 124 180 80 143 180 339 80 253 1...
output:
3 498 395 76 297 378 61 84 345 46 56 283 381 18 420 173 92 310 393 323 54 285 89 22 454 255 36 456 382 263 292 462 260 208 498 380 123 194 359 126 449 171 238 106 424 73 217 210 441 82 48 286 262 135 298 256 469 247 269 245 200 500 197 488 59 203 276 317 190 445 96 110 265 279 2 376 466 11 131 163 9...
result:
ok
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3788kb
input:
500 387 488 301 488 301 413 13 413 13 265 176 265 176 398 74 398 74 241 241 415 386 415 386 448 210 448 210 285 147 285 147 264 19 264 19 314 314 335 54 335 54 261 261 484 425 484 350 425 156 350 156 164 164 420 8 420 8 309 230 309 230 441 408 441 183 408 183 410 204 410 204 318 151 318 151 328 328 ...
output:
10 219 153 198 137 292 276 18 21 477 399 215 163 138 53 445 488 385 400 213 346 62 365 249 166 221 210 352 171 86 358 434 441 130 69 253 269 449 235 410 65 468 247 334 116 144 295 28 227 289 272 189 344 274 425 222 136 497 314 308 456 31 123 366 455 472 437 44 206 370 201 229 103 431 180 415 122 218...
result:
wrong answer