/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/rust-murderer * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include #include using namespace std; // We use BFS here. Since the graph is huge but sparse, we can add our custom exit condition. map adj[200001]; int visited[200001],q[200001],dis[200001]; int main() { int tt; scanf("%d",&tt); while (tt--) { int n,m; scanf("%d %d",&n,&m); for (int i=0;i<=n;i++) adj[i].clear(); for (int i=0;i=n) break; be++; } for (int i=1;i<=n;i++) if (i!=s) printf("%d ",dis[i]); printf("\n"); } }