100652024-03-25 21:41:26szilPletykacpp17Wrong answer 63/10092ms20040 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;
        vis[x] = 0;
        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);
        }

        q.pop();
        for (int u : now) {
            for (int v : g[u]) {
                if (vis[v] == -1) {
                    q.push(v);
                    vis[v] = day + 1;
                }
                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
base63/100
1Accepted0/04ms7392 KiB
2Wrong answer0/019ms10200 KiB
3Accepted2/24ms7796 KiB
4Partially correct1/24ms8052 KiB
5Wrong answer0/24ms8440 KiB
6Wrong answer0/27ms8908 KiB
7Accepted4/47ms9132 KiB
8Wrong answer0/48ms9584 KiB
9Accepted4/48ms9844 KiB
10Accepted4/48ms9816 KiB
11Wrong answer0/419ms11328 KiB
12Accepted4/417ms11332 KiB
13Partially correct2/428ms13124 KiB
14Wrong answer0/429ms13204 KiB
15Wrong answer0/641ms14996 KiB
16Accepted6/639ms14988 KiB
17Wrong answer0/650ms16324 KiB
18Accepted6/652ms16348 KiB
19Accepted6/652ms17296 KiB
20Wrong answer0/654ms17496 KiB
21Accepted6/652ms17256 KiB
22Accepted6/657ms17388 KiB
23Accepted6/692ms19968 KiB
24Accepted6/690ms20040 KiB