12132022-03-25 19:35:41Szin AttilaPletykacpp14Wrong answer 39/100187ms60336 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 ll maxN = 2e5 + 5;
const ll MOD = 1e9 + 7;


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

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

    for(ll &i : a) cin >> i;

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

    vector<vector<ll> > pref(2*n+1, vector<ll>(2, 0));

    for(ll i = 0; i < k; i++) {
        if(g[a[i]].size() > 0) {
            tav[a[i]][0] = 1;
            pref[1][0]++;
        }
        else {
            pref[1][0]++;
            pref[2][0]--;
        }
    }

    queue<pair<ll, ll >> sor;
    for(ll i : a) sor.push({i, 0});

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

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

        for(ll 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]][1-cur.second]++;
            sor.push({sz, 1-cur.second});
        }
    }

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

    vector<ll> mo(2*n+1, 0);
    ll maxi = -1, ind = -1;
    for(ll i = 1; i < mo.size(); i++) {
        mo[i] = pref[i][1-i%2];
        if(i > 2) mo[i] += mo[i-2];

        if(mo[i] > maxi) {
            maxi = mo[i];
            ind = i;
        }
    }
    cout << maxi << "\n" << ind << "\n";
    for(ll i = 1; i <= ind; i++) cout << mo[i] << ' ';
    cout << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base39/100
1Accepted0/02ms1820 KiB
2Wrong answer0/029ms16224 KiB
3Accepted2/21ms2224 KiB
4Partially correct1/22ms2708 KiB
5Wrong answer0/23ms3216 KiB
6Wrong answer0/24ms4560 KiB
7Accepted4/44ms4612 KiB
8Wrong answer0/49ms6960 KiB
9Accepted4/48ms7056 KiB
10Accepted4/48ms7156 KiB
11Wrong answer0/428ms16980 KiB
12Accepted4/427ms17316 KiB
13Partially correct2/443ms27272 KiB
14Wrong answer0/448ms27916 KiB
15Wrong answer0/6115ms37900 KiB
16Accepted6/679ms38720 KiB
17Time limit exceeded0/6120ms49204 KiB
18Accepted6/6115ms50248 KiB
19Accepted6/6112ms56116 KiB
20Wrong answer0/6119ms56820 KiB
21Time limit exceeded0/6123ms56820 KiB
22Time limit exceeded0/6149ms56824 KiB
23Time limit exceeded0/6187ms60336 KiB
24Time limit exceeded0/6148ms32664 KiB