Task: | Light rail connections |
Sender: | asdf4321 |
Submission time: | 2024-11-16 16:04:30 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.01 s | details |
#3 | WRONG ANSWER | 0.01 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.01 s | details |
#12 | ACCEPTED | 0.02 s | details |
#13 | ACCEPTED | 0.01 s | details |
#14 | ACCEPTED | 0.01 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.01 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.01 s | details |
#28 | ACCEPTED | 0.01 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.01 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.01 s | details |
Code
#include <bits/stdc++.h> using namespace std; #define int long long #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() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; signed main() { #ifdef LOCAL freopen(".inp", "r", stdin); freopen(".out", "w", stdout); #endif int n, m; cin >> n >> m; vector<set<int>> adj(n); set<pii> es; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; if (u > v) swap(u, v); es.insert({u, v}); adj[u].insert(v); adj[v].insert(u); } int need = 3 * n; // int need = 7; while (sz(es) > need) { for (int u = 0; u < n; u++) { if (sz(adj[u]) > 3) { int curdeg = sz(adj[u]); vector<int> will; for (int v : adj[u]) { if (curdeg == 3) break; if (sz(adj[v]) == 2 || sz(adj[v]) > 3) { curdeg--; will.push_back(v); } } for (int v : will) { int uu = u, vv = v; if (uu > vv) swap(uu, vv); es.erase({uu, vv}); adj[uu].erase(vv); adj[vv].erase(uu); } } } } cout << sz(es) << '\n'; for (auto x : es) { cout << x.first + 1 << ' ' << x.second + 1 << '\n'; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5 8 1 2 1 3 1 4 2 3 ... |
correct output |
---|
8 1 2 1 3 1 4 2 3 ... |
user output |
---|
8 1 2 1 3 1 4 2 3 ... |
Test 2
Verdict: WRONG ANSWER
input |
---|
100 2451 1 2 1 3 1 4 1 5 ... |
correct output |
---|
289 1 2 1 3 1 4 1 5 ... |
user output |
---|
282 1 48 1 49 1 50 2 48 ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
100 1206 1 2 26 27 51 52 76 77 ... |
correct output |
---|
282 1 2 1 3 1 4 1 5 ... |
user output |
---|
258 1 26 1 51 1 76 2 23 ... |
Test 4
Verdict: ACCEPTED
input |
---|
5 8 2 3 1 3 1 5 5 4 ... |
correct output |
---|
8 1 3 1 5 2 1 2 3 ... |
user output |
---|
8 1 2 1 3 1 4 1 5 ... |
Test 5
Verdict: ACCEPTED
input |
---|
10 10 1 2 2 5 7 10 5 4 ... |
correct output |
---|
10 1 2 1 6 2 5 2 10 ... |
user output |
---|
10 1 2 1 6 2 5 2 6 ... |
Test 6
Verdict: ACCEPTED
input |
---|
10 45 1 6 1 7 10 6 4 6 ... |
correct output |
---|
27 1 3 1 6 1 7 1 9 ... |
user output |
---|
21 1 8 1 9 1 10 2 8 ... |
Test 7
Verdict: ACCEPTED
input |
---|
100 45 42 4 39 75 99 87 9 65 ... |
correct output |
---|
45 1 13 4 96 7 26 9 65 ... |
user output |
---|
45 1 13 3 39 4 42 4 96 ... |
Test 8
Verdict: ACCEPTED
input |
---|
100 400 19 66 48 11 34 85 22 9 ... |
correct output |
---|
296 1 27 1 38 1 63 2 44 ... |
user output |
---|
172 1 27 1 38 1 63 2 45 ... |
Test 9
Verdict: ACCEPTED
input |
---|
100 500 17 75 80 65 89 16 65 73 ... |
correct output |
---|
297 1 55 1 62 1 75 1 78 ... |
user output |
---|
183 1 85 1 86 1 96 2 62 ... |
Test 10
Verdict: ACCEPTED
input |
---|
1000 500 989 549 7 137 716 180 20 265 ... |
correct output |
---|
500 1 931 7 137 11 781 14 305 ... |
user output |
---|
500 1 931 3 634 4 345 4 560 ... |
Test 11
Verdict: ACCEPTED
input |
---|
1000 5000 911 615 730 255 283 617 821 101 ... |
correct output |
---|
2992 1 359 1 579 1 688 1 826 ... |
user output |
---|
1838 1 688 1 826 1 908 2 566 ... |
Test 12
Verdict: ACCEPTED
input |
---|
1000 10000 116 615 301 287 869 274 717 549 ... |
correct output |
---|
2997 1 165 1 496 1 661 2 22 ... |
user output |
---|
2196 1 848 1 871 1 878 2 927 ... |
Test 13
Verdict: ACCEPTED
input |
---|
1000 1000 395 816 73 640 124 192 920 419 ... |
correct output |
---|
1000 2 903 3 634 4 959 5 274 ... |
user output |
---|
1000 1 875 2 903 3 634 4 959 ... |
Test 14
Verdict: ACCEPTED
input |
---|
100 4000 18 66 63 12 50 12 48 78 ... |
correct output |
---|
297 1 8 1 34 1 40 1 43 ... |
user output |
---|
283 1 97 1 98 1 99 2 97 ... |
Test 15
Verdict: ACCEPTED
input |
---|
1 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 16
Verdict: ACCEPTED
input |
---|
10 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 17
Verdict: ACCEPTED
input |
---|
100 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 18
Verdict: ACCEPTED
input |
---|
1000 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 19
Verdict: ACCEPTED
input |
---|
5 6 5 1 4 1 5 2 4 2 ... |
correct output |
---|
6 4 1 4 2 4 3 5 1 ... |
user output |
---|
6 1 4 1 5 2 4 2 5 ... |
Test 20
Verdict: ACCEPTED
input |
---|
9 12 6 8 7 8 6 5 7 5 ... |
correct output |
---|
12 6 2 6 5 6 8 7 1 ... |
user output |
---|
12 1 7 1 9 2 6 2 7 ... |
Test 21
Verdict: ACCEPTED
input |
---|
37 54 37 31 14 31 37 15 14 15 ... |
correct output |
---|
54 6 2 6 7 6 19 6 30 ... |
user output |
---|
54 1 20 1 26 2 6 2 28 ... |
Test 22
Verdict: ACCEPTED
input |
---|
397 594 370 81 16 81 370 215 16 215 ... |
correct output |
---|
594 4 19 4 31 4 60 4 110 ... |
user output |
---|
594 1 208 1 342 2 7 2 247 ... |
Test 23
Verdict: ACCEPTED
input |
---|
997 1494 555 594 295 594 555 422 295 422 ... |
correct output |
---|
1494 6 214 6 280 6 455 6 472 ... |
user output |
---|
1494 1 655 1 945 2 607 2 965 ... |
Test 24
Verdict: ACCEPTED
input |
---|
6 8 5 3 6 3 5 4 6 4 ... |
correct output |
---|
8 5 1 5 2 5 3 5 4 ... |
user output |
---|
8 1 5 1 6 2 5 2 6 ... |
Test 25
Verdict: ACCEPTED
input |
---|
11 16 6 5 11 5 6 3 11 3 ... |
correct output |
---|
16 2 1 2 7 2 8 2 9 ... |
user output |
---|
16 1 2 1 11 2 7 2 8 ... |
Test 26
Verdict: ACCEPTED
input |
---|
46 72 20 46 33 46 20 15 33 15 ... |
correct output |
---|
72 2 4 2 5 2 10 2 11 ... |
user output |
---|
72 1 16 1 43 2 4 2 5 ... |
Test 27
Verdict: ACCEPTED
input |
---|
496 792 129 244 128 244 129 230 128 230 ... |
correct output |
---|
792 3 15 3 29 3 428 3 447 ... |
user output |
---|
792 1 316 1 437 2 432 2 484 ... |
Test 28
Verdict: ACCEPTED
input |
---|
996 1592 940 446 864 446 940 50 864 50 ... |
correct output |
---|
1592 2 362 2 482 2 545 2 572 ... |
user output |
---|
1592 1 531 1 614 2 362 2 482 ... |
Test 29
Verdict: ACCEPTED
input |
---|
3 2 3 1 2 1 |
correct output |
---|
2 2 1 3 1 |
user output |
---|
2 1 2 1 3 |
Test 30
Verdict: ACCEPTED
input |
---|
5 4 5 3 1 3 1 2 4 2 |
correct output |
---|
4 1 2 1 3 4 2 5 3 |
user output |
---|
4 1 2 1 3 2 4 3 5 |
Test 31
Verdict: ACCEPTED
input |
---|
19 18 5 2 1 2 1 4 15 4 ... |
correct output |
---|
18 1 2 1 4 5 2 7 10 ... |
user output |
---|
18 1 2 1 4 2 5 3 12 ... |
Test 32
Verdict: ACCEPTED
input |
---|
199 198 20 93 53 93 53 7 152 7 ... |
correct output |
---|
198 3 44 3 128 5 18 5 184 ... |
user output |
---|
198 1 87 1 154 2 34 2 148 ... |
Test 33
Verdict: ACCEPTED
input |
---|
999 998 481 471 242 471 242 95 525 95 ... |
correct output |
---|
998 2 267 2 303 3 378 3 644 ... |
user output |
---|
998 1 52 1 180 2 267 2 303 ... |
Test 34
Verdict: ACCEPTED
input |
---|
4 4 2 4 1 4 2 3 1 3 |
correct output |
---|
4 1 3 1 4 2 3 2 4 |
user output |
---|
4 1 3 1 4 2 3 2 4 |
Test 35
Verdict: ACCEPTED
input |
---|
7 8 2 7 4 7 2 5 4 5 ... |
correct output |
---|
8 2 5 2 7 4 1 4 3 ... |
user output |
---|
8 1 4 1 6 2 5 2 7 ... |
Test 36
Verdict: ACCEPTED
input |
---|
28 36 22 9 24 9 22 5 24 5 ... |
correct output |
---|
36 3 8 3 18 3 21 3 27 ... |
user output |
---|
36 1 11 1 26 2 6 2 25 ... |
Test 37
Verdict: ACCEPTED
input |
---|
298 396 293 290 133 290 293 228 133 228 ... |
correct output |
---|
396 1 62 1 112 1 174 1 250 ... |
user output |
---|
396 1 62 1 112 1 174 1 250 ... |
Test 38
Verdict: ACCEPTED
input |
---|
1000 1332 949 882 156 882 949 515 156 515 ... |
correct output |
---|
1332 2 508 2 774 2 885 2 921 ... |
user output |
---|
1332 1 674 1 880 2 508 2 774 ... |