美文网首页
2019-01-28 [HDU-2181]

2019-01-28 [HDU-2181]

作者: 林锦天 | 来源:发表于2019-01-28 11:23 被阅读0次

    include<iostream>

    include<cstring>

    using namespace std;
    long long a[21][3];
    int vist[25];
    long long st[22];
    int s = 1,p=0,o=1;
    void d(long long n,long long s)
    {
    st[s] = n;
    vist[n] = 1;

    for (int i = 0; i < 3; i++)
    {
        if (s == 20 && a[n][i] == st[1])
        {
            cout << o << ": ";
            for (int i = 1; i < 21; i++)
            {
                cout << " " << st[i];
            }
            cout <<" " <<st[1]<< endl; o++;
        }
        if (vist[a[n][i]] != 1)
        {       
            d(a[n][i],s+1); 
        }
    }   
    vist[n] = 0;
    

    }
    int main()
    {
    for (int i = 1; i <= 20; i++)
    cin >> a[i][0] >> a[i][1] >> a[i][2];
    long long n;
    while (cin >> n && n != 0)
    {
    memset(vist, 0, sizeof(vist));
    d(n,1);
    }

    }

    相关文章

      网友评论

          本文标题:2019-01-28 [HDU-2181]

          本文链接:https://www.haomeiwen.com/subject/qefajqtx.html