257882026-03-02 19:48:55lorantbPletykacpp17Wrong answer 21/100196ms28980 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n,m,k; cin >> n >> m >> k;
    vector<vector<bool>> x(n+1, vector<bool>(2));
    vector<vector<int>> y(n+1, vector<int>(2));
    vector<vector<int>> g(n+1);
    vector<int> time(1000000);	
    queue<int> q;
    for(int i = 0; i < k; i++) {
        int a; cin >> a;
        x[a][0] = true;
        y[a][0] = 1;
        q.push(a);
    }
    for(int i = 0; i < m; i++) {
        int a,b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q.size() != 0) {
        int v = q.front();  q.pop();
        if(x[v][0] == true) {
            for(int i : g[v]) {
                if(x[i][1] == false) {
                    y[i][1] = y[v][0]+1;
                    x[i][1] = true;
                    q.push(i);
                }
            }
        }
        if(x[v][1] == true) {
            for(int i : g[v]) {
                if(x[i][0] == false) {
                    y[i][0] = y[v][1]+1;
                    x[i][0] = true;
                    q.push(i);
                }
            }
        }
    }
    int one=0,two=0;
    long long o=0,t=0;
    for(int i = 1; i <= n; i++) {
        if(x[i][0]) {
            one++;
            o=max(o,y[i][0]);
            time[y[i][0]]++;
        }
        if(x[i][1]) {
            two++;
            t=max(t,y[i][1]);
            time[y[i][1]]++;
        }
    }
    for(int i = 3; i < (int)time.size(); i++) {
        time[i] += time[i-2];
    }
    if(one > two || (one == two && o < t)) {
        cout << one << endl << o << endl;
        for(int i = 1; i <= o; i++) {
            cout << time[i] << " ";
        }
    }
    else {
        cout << two << endl << t << endl;
        for(int i = 1; i <= t; i++) {
            cout << time[i] << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base21/100
1Accepted0/08ms8244 KiB
2Wrong answer0/046ms13620 KiB
3Accepted2/29ms8260 KiB
4Partially correct1/210ms8244 KiB
5Wrong answer0/212ms8504 KiB
6Wrong answer0/216ms9148 KiB
7Accepted4/414ms9012 KiB
8Wrong answer0/421ms10028 KiB
9Accepted4/420ms9972 KiB
10Accepted4/418ms10052 KiB
11Wrong answer0/446ms13540 KiB
12Accepted4/448ms13620 KiB
13Partially correct2/472ms17288 KiB
14Wrong answer0/490ms17284 KiB
15Wrong answer0/6112ms20856 KiB
16Time limit exceeded0/6129ms21044 KiB
17Time limit exceeded0/6150ms24628 KiB
18Time limit exceeded0/6185ms24628 KiB
19Time limit exceeded0/6155ms26164 KiB
20Time limit exceeded0/6196ms26164 KiB
21Time limit exceeded0/6162ms26164 KiB
22Time limit exceeded0/6175ms26164 KiB
23Time limit exceeded0/6186ms28980 KiB
24Time limit exceeded0/6185ms28384 KiB