#include<iostream> #include<vector> #include<algorithm> #include<stack> #define N 10010 using namespace std; vector<long int> head[N]; stack<long int> way; long int n; bool visited[N][N]; bool vis[N]; long long int d[N]…
#include<iostream> #include<vector> #include<algorithm> #include<stack> #define N 10010 using namespace std; vector<long int> head[N]; stack<long int> way; long int n; bool visited[N][N]; bool vis[N]; long long int d[N]…
http://acm.nyist.net/JudgeOnline/problem.php?pid=42题目链接 #include <cstdio> #include <cstring> #define CLR(arr) memset(arr,0,sizeof(arr)) #define P 1001 int G[P],fa[P]; int find(int x){return x==fa[x]?x:x=find(fa[x]);} int main() { int n,a,b…