12332022-03-27 14:28:09Valaki2Turista járatokcpp14Wrong answer 0/100162ms44660 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]) {
            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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms3848 KiB
2Accepted8ms5140 KiB
subtask20/10
3Accepted2ms4056 KiB
4Accepted2ms4060 KiB
5Wrong answer2ms4068 KiB
6Wrong answer2ms4076 KiB
7Wrong answer2ms4084 KiB
subtask30/10
8Wrong answer2ms4084 KiB
9Accepted2ms4084 KiB
10Accepted2ms4092 KiB
11Accepted3ms4128 KiB
12Accepted4ms4560 KiB
subtask40/10
13Accepted6ms5056 KiB
14Accepted2ms4256 KiB
15Accepted2ms4304 KiB
16Accepted3ms4492 KiB
17Wrong answer162ms33556 KiB
18Wrong answer48ms14280 KiB
19Wrong answer61ms17500 KiB
20Wrong answer41ms16528 KiB
subtask50/10
21Accepted8ms12576 KiB
22Wrong answer2ms11636 KiB
23Wrong answer2ms11644 KiB
24Wrong answer2ms11660 KiB
25Wrong answer89ms29968 KiB
26Wrong answer7ms15592 KiB
27Wrong answer7ms15740 KiB
subtask60/60
28Wrong answer2ms14808 KiB
29Accepted2ms14964 KiB
30Accepted4ms15020 KiB
31Accepted4ms15224 KiB
32Wrong answer4ms15316 KiB
33Accepted4ms15552 KiB
34Accepted8ms16124 KiB
35Accepted9ms16384 KiB
36Accepted8ms16420 KiB
37Wrong answer160ms44660 KiB
38Wrong answer37ms25428 KiB
39Wrong answer39ms26348 KiB
40Wrong answer37ms27260 KiB
41Wrong answer41ms28140 KiB
42Wrong answer37ms28896 KiB
43Wrong answer37ms29948 KiB
44Wrong answer35ms30680 KiB
45Wrong answer56ms33956 KiB
46Wrong answer35ms33064 KiB
47Wrong answer39ms33828 KiB
48Wrong answer37ms34696 KiB
49Wrong answer39ms35768 KiB
50Wrong answer43ms36672 KiB