zoukankan      html  css  js  c++  java
  • poj1330

    简单题

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    using namespace std;

    #define maxn 10005

    bool vis[maxn];
    int father[maxn];

    int main()
    {
    //freopen("t.txt", "r", stdin);
    int t;
    scanf(
    "%d", &t);
    while (t--)
    {
    memset(father,
    -1, sizeof(father));
    memset(vis,
    0, sizeof(vis));
    int n;
    scanf(
    "%d", &n);
    int a, b;
    for (int i = 0; i < n - 1; i++)
    {
    scanf(
    "%d%d", &a, &b);
    father[b]
    = a;
    }
    scanf(
    "%d%d", &a, &b);
    while (b != -1)
    {
    vis[b]
    = true;
    b
    = father[b];
    }
    while (!vis[a])
    a
    = father[a];
    printf(
    "%d\n", a);
    }
    return 0;
    }

  • 相关阅读:
    蒟蒻的填坑计划
    现在的状态....
    date modify
    set source
    image source
    simple auth
    net
    bridge
    iptable
    namespace
  • 原文地址:https://www.cnblogs.com/rainydays/p/2087523.html
Copyright © 2011-2022 走看看