12292022-03-27 11:48:35Szin AttilaPletykacpp14Wrong answer 2/100128ms39384 KiB
#include <bits/stdc++.h>
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using ll = long long;

const int maxN = 2e5 + 5;
const int MOD = 1e9 + 7;

inline int read(){
    int res=0; char ch=getchar();
    while(ch < '0' || '9' < ch) ch=getchar();
    while('0' <= ch && ch <= '9'){
        res=(res<<3) + (res<<1)+ch-'0';
        ch=getchar();
    }
    return res;
}


int main() {
    /*freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);*/
   InTheNameOfGod;
    
    int n,m,k;
    n = read(); m = read(); k = read();

    vector<vector<int> > g(n+1), tav(n+1, vector<int>(2, -1));
    vector<int> a(k);

    for(int &i : a) i = read();

    for(int i = 0; i < m; i++) {
        int x,y;
        x = read(); y = read();
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vector<int > pref(n+3, 0);
    queue<pair<int, int > > sor;

    for(int i = 0; i < k; i++) {
        if(!g[a[i]].empty()) {
            tav[a[i]][0] = 1;
            pref[1]++;
            sor.push({a[i], 0});
        }
        else {
            pref[1]++;
            pref[3]--;
            //cout << "empty: " << a[i] << endl;
        }
    }

    while(!sor.empty()) {
        pair<int, bool> cur = sor.front();
        sor.pop();

        //cout << cur.first << ", " << cur.second << ": " << tav[cur.first][cur.second] << endl;

        for(int sz : g[cur.first]) {
            if(tav[sz][1-cur.second] != -1) continue;

            tav[sz][1-cur.second] = tav[cur.first][cur.second] + 1;
            pref[tav[sz][1-cur.second]]++;
            sor.push({sz, 1-cur.second});
        }
    }

    /*for(int i = 1; i < 7; i++) cout << pref[i][0] << ' ';
    cout << endl;
    for(int i = 1; i < 7; i++) cout << pref[i][1] << ' ';
    cout << endl;*/

    vector<int> mo(n+3, 0);
    mo[1] = pref[1];
    int maxi = mo[1], ind = 1;
    for(int i = 2; i < pref.size(); i++) { 
        mo[i] = pref[i];

        if(mo[i] > maxi) {
            maxi = mo[i];
            ind = i;
        }
    }

    cout << maxi << "\n" << ind << "\n";
    for(int i = 1; i <= ind; i++) cout << mo[i] << ' ';
    cout << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/100
1Wrong answer0/02ms1876 KiB
2Wrong answer0/016ms9120 KiB
3Accepted2/21ms2256 KiB
4Wrong answer0/21ms2496 KiB
5Wrong answer0/22ms2752 KiB
6Wrong answer0/24ms3512 KiB
7Wrong answer0/43ms3556 KiB
8Wrong answer0/44ms4712 KiB
9Wrong answer0/44ms4816 KiB
10Wrong answer0/44ms4912 KiB
11Wrong answer0/416ms9948 KiB
12Wrong answer0/417ms10276 KiB
13Wrong answer0/432ms15408 KiB
14Wrong answer0/434ms15988 KiB
15Wrong answer0/668ms21448 KiB
16Wrong answer0/657ms22276 KiB
17Wrong answer0/685ms27948 KiB
18Wrong answer0/690ms28980 KiB
19Wrong answer0/675ms32700 KiB
20Wrong answer0/679ms33876 KiB
21Wrong answer0/682ms35004 KiB
22Wrong answer0/696ms35240 KiB
23Wrong answer0/6119ms36864 KiB
24Time limit exceeded0/6128ms39384 KiB