100642024-03-25 21:19:57szilPletykacpp17Wrong answer 0/100108ms35752 KiB
#include <bits/stdc++.h>

using ll = long long;
using namespace std;

const int MAXN = 100'001;

int cnt[MAXN], vis[MAXN];
bool vis2[MAXN];
vector<int> g[MAXN];

void solve() {
    int n, m, k; cin >> n >> m >> k;
    fill(vis, vis+MAXN, -1);
    queue<int> q, q2;
    for (int i = 1; i <= k; i++) {
        int x; cin >> x;
        q.push(x);
    }
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    q.push(-1);
    q2.push(-1);
    int day = 0;
    while (q.size() > 1 || q2.size() > 1) {
        vector<int> now;
        while (q.front() != -1) {
            int u = q.front(); q.pop();
            now.emplace_back(u);
            vis[u] = day;
        }
        q.pop();
        for (int u : now) {
            for (int v : g[u]) {
                if (vis[v] == -1) q.push(v);
                else if (vis[v] == day && !vis2[v]) {
                    q2.push(v);
                    vis2[v] = true;
                }
            }
        }
        q.push(-1);
        cnt[day] += now.size();

        while (q2.front() != -1) {
            int u = q2.front(); q2.pop();
            cnt[day]++;
            for (int v : g[u]) {
                if (!vis2[v]) {
                    q2.push(v);
                    vis2[v] = true;
                }
            }
        }

        q2.pop();
        q2.push(-1);

        day++;
    }
    pair<int, int> ans = {0, 0};
    vector<int> res;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, {cnt[i], -i});
        res.emplace_back(cnt[i]);
        cnt[i+2] += cnt[i];
    }
    cout << ans.first << "\n" << -ans.second+1 << "\n";
    for (int i = 0; i <= -ans.second; i++) {
        cout << res[i] << " ";
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Accepted0/04ms7384 KiB
2Wrong answer0/020ms10472 KiB
3Wrong answer0/24ms8404 KiB
4Wrong answer0/24ms8480 KiB
5Wrong answer0/24ms8656 KiB
6Wrong answer0/26ms8964 KiB
7Wrong answer0/47ms9272 KiB
8Wrong answer0/49ms10144 KiB
9Wrong answer0/48ms10328 KiB
10Wrong answer0/48ms10424 KiB
11Wrong answer0/421ms12460 KiB
12Wrong answer0/419ms12784 KiB
13Wrong answer0/428ms14952 KiB
14Wrong answer0/432ms15524 KiB
15Wrong answer0/643ms18120 KiB
16Wrong answer0/641ms19004 KiB
17Wrong answer0/652ms21348 KiB
18Wrong answer0/654ms22652 KiB
19Wrong answer0/659ms24696 KiB
20Wrong answer0/657ms25860 KiB
21Wrong answer0/659ms27120 KiB
22Wrong answer0/661ms28308 KiB
23Wrong answer0/6108ms33612 KiB
24Wrong answer0/6108ms35752 KiB