168632025-05-14 11:04:33AblablablaPletykacpp17Time limit exceeded 94/100143ms14132 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    vector<int> kezd(k);
    for(int &x : kezd){
        cin >> x;
        x--;
    }

    vector<vector<int>> csucsok(n, vector<int>());
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;

        csucsok[a].push_back(b);
        csucsok[b].push_back(a);
    }

    queue<pii> bejar;
    vector<int> ans;
    vector<vector<bool>> bejart(n, vector<bool>(2, 0));
    int elsoben = 0;

    for(int x : kezd){
        bejar.push({x, 0});
        bejart[x][0] = 1;
    }

    while(!bejar.empty()){
        auto [akt, t] = bejar.front();
        bejar.pop();

        if(t == 0 && csucsok[akt].size() == 0){
            elsoben++;
        }

        if(t >= ans.size()){
            ans.push_back(1);

            if(t >= 2){
                ans[t] += ans[t - 2];

                if(t == 2){
                    ans[t] -= elsoben;
                }
            }
        } else{
            ans[t]++;
        }

        t++;

        for(int x : csucsok[akt]){
            if(bejart[x][t % 2]) continue;

            bejart[x][t % 2] = 1;
            bejar.push({x, t});
        }
    }

    int maxi = 0, ind = -1;
    for(int i = 0; i < ans.size(); i++){
        if(maxi < ans[i]){
            maxi = ans[i];
            ind = i + 1;
        }
    }

    cout << maxi << "\n" << ind << "\n";
    for(int i = 0; i < ind; i++){
        cout << ans[i] << " ";
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base94/100
1Accepted0/01ms500 KiB
2Accepted0/020ms4404 KiB
3Accepted2/21ms316 KiB
4Accepted2/22ms316 KiB
5Accepted2/22ms568 KiB
6Accepted2/24ms820 KiB
7Accepted4/44ms868 KiB
8Accepted4/47ms1588 KiB
9Accepted4/47ms1564 KiB
10Accepted4/46ms1724 KiB
11Accepted4/420ms4312 KiB
12Accepted4/419ms4148 KiB
13Accepted4/437ms6744 KiB
14Accepted4/435ms6992 KiB
15Accepted6/665ms9464 KiB
16Accepted6/652ms9656 KiB
17Accepted6/674ms12248 KiB
18Accepted6/697ms12096 KiB
19Accepted6/696ms13108 KiB
20Accepted6/678ms13236 KiB
21Accepted6/681ms13108 KiB
22Accepted6/6114ms13488 KiB
23Time limit exceeded0/6143ms14132 KiB
24Accepted6/6115ms14132 KiB