156792025-02-21 17:53:01999Fertőzési sorozat (50 pont)cpp17Wrong answer 0/501ms508 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e12;

signed main() {cout<<-1;return 0;
    int n,m,k;cin>>n>>m>>k;
    vector<vector<int>> fw(n, vector<int>(n,INF));
    vector<int> v(k);
    for(int &i:v){cin>>i;i--;}
    for(int i = 0;i<m;i++){
        int a,b;cin>>a>>b;
        fw[--a][--b]=1;
        fw[b][a]=1;
    }
    for(int i = 0;i<n;i++)fw[i][i]=0;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<n;j++){
            for(int k = 0;k<n;k++){
                fw[k][j]=min(fw[k][j],fw[i][k]+fw[i][j]);
            }
        }
    }//for(int i = 0;i<n;i++){for(int j = 0;j<n;j++)cerr<<fw[i][j]<<' ';cerr<<endl;}
    vector<int> ans;
    for(int i = 0;i<n;i++){
        bool boo=true;
        for(int j=0;j<k;j++){
            int l=v[j];
            if(j==0)continue;
            if(!(fw[i][l]-fw[i][v[j-1]]<=1&&fw[i][l]-fw[i][v[j-1]]>=0)){
                boo=false;
                break;
            }
        }
        if(boo){
            ans.push_back(i);
        }
    }
    cout<<ans.size()<<endl;
    for(int i:ans)cout<<i+1<<' ';
    cout<<endl;
}
 
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms500 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/01ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/11ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/21ms500 KiB
14Wrong answer0/21ms316 KiB
15Wrong answer0/21ms316 KiB
16Wrong answer0/21ms316 KiB
17Wrong answer0/21ms316 KiB
18Wrong answer0/11ms316 KiB
19Wrong answer0/11ms316 KiB
20Wrong answer0/11ms316 KiB
21Wrong answer0/11ms316 KiB
22Wrong answer0/11ms316 KiB
23Wrong answer0/11ms316 KiB
24Wrong answer0/11ms500 KiB
25Wrong answer0/11ms316 KiB
26Wrong answer0/11ms508 KiB
27Wrong answer0/11ms316 KiB
28Wrong answer0/11ms316 KiB
29Wrong answer0/11ms508 KiB
30Wrong answer0/11ms316 KiB
31Wrong answer0/11ms316 KiB
32Wrong answer0/11ms316 KiB
33Wrong answer0/11ms316 KiB
34Wrong answer0/11ms316 KiB
35Wrong answer0/11ms508 KiB
36Wrong answer0/11ms316 KiB
37Wrong answer0/11ms508 KiB
38Wrong answer0/11ms316 KiB
39Wrong answer0/11ms320 KiB
40Wrong answer0/11ms316 KiB