| 15627 | 2025-02-21 11:21:19 | linhnk | Fertőzési sorozat (50 pont) | cpp17 | Compilation error |
#include <iostream>
#include <bits/stdc++.h>
#include<queue>
using namespace std;
int main()
{
int n, m, k, a, b;
cin>>n>>m>>k;
vector<int> hal(k);
vector<vector<int>> cs(n+1);
vector<int> erdos(n+1, -1);
vector<bool> alap(n+1, false);
vector<bool> been(n+1, false);
queue<int> q;
vector<int> d;
bool jaj=true;
for(int i=0; i<k; i++){
cin>>hal[i];
alap[hal[i]]=true;
}
alap[hal[0]]=false;
for(int i=0; i<m; i++){
cin>>a>>b;
cs[a].push_back(b);
cs[b].push_back(a);
}
for(int h=1; h<n+1; h++){
if(alap[h])
continue;
jaj=true;
erdos.assign(n+1, -1);
been.assign(n+1, false);
//cout<<h<<endl;
erdos[h]=0;
q.push(h);
/*been[h]=true;
for(auto x:cs[h]){
q.push(x);
erdos[x]=1;
//cout<<x<<"";
}*/
//cout<<endl;
while(q.size()>0){
if(!been[q.front()]){
been[q.front()]=true;
for(auto x:cs[q.front()]){
if(erdos[x]==-1){
erdos[x]=erdos[q.front()]+1;
q.push(x);
//cout<<q.front()<<" "<<x<<endl;
}
}
}
q.pop();
}
for(int i=0; i<k-1; i++){
if(erdos[hal[i]]+1<erdos[hal[i+1]]){
jaj=false;
break;
}
}
if(!jaj){
continue;
}
for(auto x:erdos){
if(x!=-1){
if(!alap[x]&&x<erdos[hal.back()]&&x=>erdos[hal[0]]){
jaj=false;
break;
}
}
}
if(jaj){
d.push_back(h);
}
}
cout<<d.size()<<endl;
for(auto x:d){
cout<<x<<" ";
}
/*cout<<endl<<erdos.size()<<endl;
for(auto x:erdos){
cout<<x<<" ";
}*/
}
open /var/local/lib/isolate/407/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:70:53: error: expected primary-expression before '>' token
70 | if(!alap[x]&&x<erdos[hal.back()]&&x=>erdos[hal[0]]){
| ^