zoukankan      html  css  js  c++  java
  • 6.3每日一题题解

    Game On Leaves

    涉及知识点:

    • 思维/博弈

    solution:

    • 首先我们要知道无根树的概念(就是任何一个节点都能当做根),然后仔细审题
    • 接下来你会发现,无论如何变化,最终和X 有关系的只是,最后两个与X相连的节点,
    • 设置 第一个节点为x1 ,第二个为x2。那么当取走x1的是Ashish,那么获胜的是Ayush,否则相反。
    • 所以只需要判断(n-2)的奇偶就可以了
    • 特别要关心当n为1的时候Ayush可以直接获胜

    std:

    #include <bits/stdc++.h>
    
    using namespace std;
    const int N = 20;
    
    int n,wight;
    int ans=0x3f3f3f3f;
    int root[N],car[N];
    
    
    
    int main()
    {
        int t,cnt =0 ;
        int   n,m,k;
        cin >>t ;
        while(t--){
                cin >>n>> m;
                memset(root,0,sizeof(root));
                for(int i=1;i<n;i++){
                    int u,v ;cin >>u >> v;
                 root[u]++;
                 root[v]++ ;
                }
                if(root[m]>1&&(n-2)%2==1)cout<<"Ashish"<<endl;
                else cout<<"Ayush"<<endl;
        }
    
    }
    
  • 相关阅读:
    添加右键菜单
    闭包和迭代器
    函数的进阶
    函数入门
    文件操作
    深浅拷贝
    小数据池和再谈编码
    字典
    list tuple
    int bool str
  • 原文地址:https://www.cnblogs.com/QFNU-ACM/p/13035270.html
Copyright © 2011-2022 走看看