CF1363C

题目简化和分析:

首先注意特判 $ x $ 在叶子节点上 ( 即度为 \(1\) )。

因为每人都采用最优策略所以不可能有人执着的为别人开路。
就是不在同一颗子树上挣扎,会从外围不断清理。
但是每步必须删除所以就看谁先将周围的点删除,这就别成了对奇偶性的判断。

至于先删哪一个节点我们没必要考虑。

  • $ n $ 为奇数 不行
  • $ n $ 为偶数 可行

Solution:

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

const int N=1e3+50;
const int M=1e5+50;
const int Mod=1e9+7;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int t,n,x;
int siz[N];
int main()
{
	t=read();
	while(t--){
		memset(siz,0,sizeof(siz));
		n=read(),x=read();
		for(int i=1;i<n;++i){
			int u,v;
			u=read(),v=read();
			++siz[u],++siz[v];
		}
		if(siz[x]<2){
			printf("Ayush\n");
		}else{
			if(n&1){
				printf("Ashish\n");
			}else{
				printf("Ayush\n");
			}
		}
	}
	return 0;
}

posted @ 2022-08-03 21:06  RVG  阅读(32)  评论(0)    收藏  举报