11725
[실2] 11725 - 트리의 부모 찾기
#include #include #include #include using namespace std; #define MAX_SIZE 100001 vector graph[MAX_SIZE]; int arr[MAX_SIZE]; bool vis[MAX_SIZE]; int main() { int n; cin >> n; for (int i = 1; i > y >> x; graph[y].push_back(x); graph[x].push_back(y); } stack s; s.push(1); vis[1] = true; while (!s.empty()) { auto idx = s.top(); s.pop(); for (int i = 0; i < graph[idx].size(..