#include #include #include #include #include #define SHOW(d) {std::cout<<#d<<"\t:"< tmp(a);\ std::cout << #a << "\t:";\ for(size_t i=0; i& t) const{ return mValue==t.second; } }; int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n, m, k; std::cin >> n >> m >> k; std::vector>> town(n); for(int i=0; i> a >> b >> c; town[a-1].push_back(std::make_pair(b-1, c)); town[b-1].push_back(std::make_pair(a-1, c)); } //SHOWTOWN(town); std::queue searchQueue; for(int i=0; i> d; int queueSize = searchQueue.size(); for(int j=0; j> t(town[searchNum]); searchQueue.pop(); auto it = std::find_if(t.begin(), t.end(), Comp(d)); if(it!=t.end()){ searchQueue.push(it->first); } } //SHOW(i); //SHOWQUEUE(searchQueue); } int searchQueueNum = searchQueue.size(); std::vector ans(searchQueueNum); for(int i=0; i