168632025-05-14 11:04:33AblablablaPletykacpp17Időlimit túllépés 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";
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base94/100
1Elfogadva0/01ms500 KiB
2Elfogadva0/020ms4404 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/22ms316 KiB
5Elfogadva2/22ms568 KiB
6Elfogadva2/24ms820 KiB
7Elfogadva4/44ms868 KiB
8Elfogadva4/47ms1588 KiB
9Elfogadva4/47ms1564 KiB
10Elfogadva4/46ms1724 KiB
11Elfogadva4/420ms4312 KiB
12Elfogadva4/419ms4148 KiB
13Elfogadva4/437ms6744 KiB
14Elfogadva4/435ms6992 KiB
15Elfogadva6/665ms9464 KiB
16Elfogadva6/652ms9656 KiB
17Elfogadva6/674ms12248 KiB
18Elfogadva6/697ms12096 KiB
19Elfogadva6/696ms13108 KiB
20Elfogadva6/678ms13236 KiB
21Elfogadva6/681ms13108 KiB
22Elfogadva6/6114ms13488 KiB
23Időlimit túllépés0/6143ms14132 KiB
24Elfogadva6/6115ms14132 KiB