1234 | 2022-03-27 14:33:04 | Valaki2 | Turista járatok | cpp14 | Wrong answer 0/100 | 156ms | 44612 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int maxn = 40000;
int n, m, k;
vector<pair<int, int> > g[maxn + 1];
bool vis[maxn + 1];
vector<int> ans;
void dfs(int cur, int ok) {
if(ok) {
ans.pb(cur);
}
vis[cur] = true;
for(pair<int, int> nei : g[cur]) {
if(!vis[nei.fi] && cur != nei.fi) {
dfs(nei.fi, max(ok, nei.se));
}
}
}
void solve() {
cin >> n >> m >> k;
for(int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
if(i <= k) {
g[a].pb(mp(b, 1));
g[b].pb(mp(a, 1));
} else {
g[a].pb(mp(b, 0));
g[b].pb(mp(a, 0));
}
}
dfs(1, 0);
sort(ans.begin(), ans.end());
cout << (int) ans.size() << "\n";
for(int x : ans) {
cout << x << " ";
}
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 3872 KiB | ||||
2 | Accepted | 8ms | 5028 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 2ms | 4060 KiB | ||||
4 | Accepted | 2ms | 4108 KiB | ||||
5 | Wrong answer | 2ms | 4064 KiB | ||||
6 | Wrong answer | 2ms | 4144 KiB | ||||
7 | Wrong answer | 2ms | 4084 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 2ms | 4088 KiB | ||||
9 | Accepted | 2ms | 4088 KiB | ||||
10 | Accepted | 2ms | 4160 KiB | ||||
11 | Accepted | 3ms | 4128 KiB | ||||
12 | Accepted | 4ms | 4564 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Accepted | 8ms | 5056 KiB | ||||
14 | Accepted | 2ms | 4252 KiB | ||||
15 | Accepted | 3ms | 4432 KiB | ||||
16 | Accepted | 3ms | 4448 KiB | ||||
17 | Wrong answer | 156ms | 33624 KiB | ||||
18 | Wrong answer | 37ms | 14144 KiB | ||||
19 | Wrong answer | 50ms | 17404 KiB | ||||
20 | Wrong answer | 37ms | 16524 KiB | ||||
subtask5 | 0/10 | ||||||
21 | Accepted | 7ms | 12572 KiB | ||||
22 | Wrong answer | 2ms | 11636 KiB | ||||
23 | Wrong answer | 2ms | 11644 KiB | ||||
24 | Wrong answer | 3ms | 11664 KiB | ||||
25 | Wrong answer | 83ms | 29888 KiB | ||||
26 | Wrong answer | 7ms | 15588 KiB | ||||
27 | Wrong answer | 7ms | 15736 KiB | ||||
subtask6 | 0/60 | ||||||
28 | Wrong answer | 2ms | 14816 KiB | ||||
29 | Accepted | 4ms | 14960 KiB | ||||
30 | Accepted | 3ms | 15016 KiB | ||||
31 | Accepted | 4ms | 15224 KiB | ||||
32 | Wrong answer | 4ms | 15312 KiB | ||||
33 | Accepted | 4ms | 15552 KiB | ||||
34 | Accepted | 7ms | 16120 KiB | ||||
35 | Accepted | 8ms | 16316 KiB | ||||
36 | Accepted | 7ms | 16420 KiB | ||||
37 | Wrong answer | 143ms | 44612 KiB | ||||
38 | Wrong answer | 34ms | 25424 KiB | ||||
39 | Wrong answer | 35ms | 26344 KiB | ||||
40 | Wrong answer | 35ms | 27260 KiB | ||||
41 | Wrong answer | 35ms | 28140 KiB | ||||
42 | Wrong answer | 35ms | 28888 KiB | ||||
43 | Wrong answer | 34ms | 29944 KiB | ||||
44 | Wrong answer | 35ms | 30688 KiB | ||||
45 | Wrong answer | 52ms | 33960 KiB | ||||
46 | Wrong answer | 41ms | 33064 KiB | ||||
47 | Wrong answer | 39ms | 33956 KiB | ||||
48 | Wrong answer | 37ms | 34696 KiB | ||||
49 | Wrong answer | 34ms | 35768 KiB | ||||
50 | Wrong answer | 35ms | 36676 KiB |