12122022-03-25 19:31:15Szin AttilaPletykacpp14Wrong answer 39/100150ms56032 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;


int main() {
   InTheNameOfGod;
    
    int n,m,k;
    cin >> n >> m >> k;

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

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

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

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

    for(int 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<int, int >> sor;
    for(int i : a) sor.push({i, 0});

    while(!sor.empty()) {
        pair<int, int> 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]][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(2*n+1, 0);
    int maxi = -1, ind = -1;
    for(int 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(int i = 1; i <= ind; i++) cout << mo[i] << ' ';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base39/100
1Accepted0/02ms1820 KiB
2Wrong answer0/037ms15724 KiB
3Accepted2/21ms2240 KiB
4Partially correct1/22ms2596 KiB
5Wrong answer0/23ms3092 KiB
6Wrong answer0/24ms4544 KiB
7Accepted4/44ms4596 KiB
8Wrong answer0/48ms7008 KiB
9Accepted4/48ms7072 KiB
10Accepted4/48ms7140 KiB
11Wrong answer0/432ms16484 KiB
12Accepted4/428ms16836 KiB
13Partially correct2/452ms26420 KiB
14Wrong answer0/454ms26984 KiB
15Wrong answer0/692ms36828 KiB
16Accepted6/694ms37632 KiB
17Wrong answer0/6118ms47704 KiB
18Accepted6/6115ms49068 KiB
19Accepted6/6115ms54540 KiB
20Time limit exceeded0/6129ms55700 KiB
21Time limit exceeded0/6131ms56032 KiB
22Time limit exceeded0/6142ms56028 KiB
23Time limit exceeded0/6150ms32660 KiB
24Time limit exceeded0/6144ms32660 KiB