Codeforces Round #646 (Div. 2) C、Game On Leaves
题目链接:C、Game On Leaves
题意:
给你一个n个节点的无根树,你每次可以删除一个叶节点。如果谁先删除x号节点谁就赢了。两个人轮流操作
题解:
如果x号节点本身就是一个叶节点,那么谁先走,谁赢
否则,也就是只有剩下两个节点时候才能移动x号节点,只需要判断n-2的奇偶性就可以了
代码:
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<deque>
#include<string.h>
#include<map>
#include <iostream>
#include <math.h>
#define Mem(a,b) memset(a,b,sizeof(a))
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int maxn=1000+10;
int in[maxn];
int main()
{
int t;
cin>>t;
while(t--)
{
int n,x;
cin>>n>>x;
memset(in,0,sizeof(in));
for(int i=1; i<=n-1; i++)
{
int u,v;
cin>>u>>v;
in[u]++;
in[v]++;
}
if(n==1||in[x]==1||n%2==0)
{
cout<<"Ayush"<<endl;
}
else
cout<<"Ashish"<<endl;
}
}
Codeforces Round #646 (Div. 2) C、Game On Leaves的更多相关文章
- Codeforces Round #646 (Div. 2)【C. Game On Leaves 题解】
题意分析 关于这道题,意思就是两个人摘叶子,谁最后摘到编号为x的谁就赢了.既然是叶子,说明其最多只有一个分支,由于题目上说了是无向图,那就是度数小于等于的节点.也就是一步步移除度数小于等于的节点,直到 ...
- Codeforces Round #437 (Div. 2)[A、B、C、E]
Codeforces Round #437 (Div. 2) codeforces 867 A. Between the Offices(水) 题意:已知白天所在地(晚上可能坐飞机飞往异地),问是否从 ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- Codeforces Round #646 (Div. 2) B. Subsequence Hate(前缀和)
题目链接:https://codeforces.com/contest/1363/problem/B 题意 可以将 $01$ 串中的 $0$ 变为 $1$.$1$ 变为 $0$,问至少需要变换多少字符 ...
- Codeforces Round #482 (Div. 2) C 、 Kuro and Walking Route(dfs)979C
题目链接:http://codeforces.com/contest/979/problem/C 大致题意 给出n个点,有n-1个边将他们链接.给出x,y,当某一路径中出现x....y时,此路不通.路 ...
- Codeforces Round #604 (Div. 2) D、E、F题解
Beautiful Sequence Beautiful Mirrors Beautiful Bracket Sequence (easy version) Beautiful Sequence \[ ...
- Codeforces Round #674 (Div. 3) C、D 题解
C.Increase and Copy #枚举 题目链接 题意 最初你有仅包含一个数字\(1\)的数组\(a\),一次操作中可对该数组进行两类操作: 从数组中选择一个元素,将该元素\(+1\): 从数 ...
- Codeforces Round #677 (Div. 3) E、G题解
E. Two Round Dances #圆排列 题目链接 题意 \(n\)(保证偶数)个人,要表演一个节目,这个节目包含两种圆形舞蹈,而每种圆形舞蹈恰好需要\(n/2\)个人,每个人只能跳一种圆形舞 ...
- Codeforces Round #667 (Div. 3) B、C、D、E 题解
抱歉B.C题咕了这么久 B. Minimum Product #枚举 #贪心 题目链接 题意 给定四个整数\(a, b, x, y\),其中\(a\geq x, b\geq y\),你可以执行不超过\ ...
随机推荐
- Openstack Nova 添加计算节点(六.一)
Openstack Nova 添加计算节点(六.一) # 重要的两点: 1 时间同步 2 yum 源 # 安装软件: yum install openstack-selinux openstack-n ...
- intellij idea2020将javaWeb项目打成war包并部署到阿里云服务器遇到java.lang. UnsupportedClass VersionError问题(已解决)
首先将javaweb项目打包成war文件(有关如何打包参考 https://jingyan.baidu.com/article/20b68a88642829386cec62f7.html.https: ...
- alter column和modify column
5.6中,发现其实alter column 和更改modify column 步骤是一样的 mysql> create table xs(name varchar(12),age int def ...
- mysql中更改字段属性实际上都做了哪些操作
mysql> set profiling=1; Query OK, 0 rows affected (0.00 sec) mysql> alter table test modify n ...
- kubernets之控制器之间的协作以及网络
一 创建一个deployment的时候整个kubernets集群的资源和事件的调用链 1.1 创建一个deployment的资源,在提交的时候,集群中的调度器,控制器以及node节点上kubele ...
- buuctf刷题之旅—web—WarmUp
启动靶机 查看源码发现source.php 代码审计,发现hint.php文件 查看hint.php文件(http://7ab330c8-616e-4fc3-9caa-99d9dd66e191.nod ...
- oralce move和shrink释放高水位
转自:https://blog.51cto.com/fengfeng688/1955137 move和shrink的共同点: 收缩段,消除部分行迁移,消除空间碎片,使数据更紧密 shrink用法: 语 ...
- 小试牛刀ElasticSearch大数据聚合统计
ElasticSearch相信有不少朋友都了解,即使没有了解过它那相信对ELK也有所认识E即是ElasticSearch.ElasticSearch最开始更多用于检索,作为一搜索的集群产品简单易用绝对 ...
- php压缩文件夹并下载到本地
/** * @param $path 要压缩的文件夹路径 * @param $filename 要生成的压缩包名称 */ public function create_zip($path,$filen ...
- 使用存储过程在mysql中批量插入数据
一.在mysql数据库中创建一张表test DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` INT (11), `name` VARCH ...