ACdream 某群赛某题 Classification of the species

http://www.acdream.net/problem.php?id=1042


题目大意:

(把物种和分类都看成节点。)

有一颗未知树,一人每次询问两个叶子节点,另一个人回答其lca,判回答之间是否有矛盾。


解法:

将每条陈述按照lca的深度由深到浅排序,然后扫一遍开始并查集。

比如说现在搞到这条陈述:x y a,那么查到xy的根节点 x_father y_father。由于是按照a的深度由深到浅搞的,所以a必然是x_father和y_father的祖先。那就分类讨论这样是否可能:

一、a是x(y)_father之一:

1、x_father和y_father都是a:ok;

2、仅x_father等于a:那么depth(y_father)必须大于depth(a),反之亦然。

二、a不是x(y)_father之一:

1、x_father和y_father相同:!ok;(x_father=y_father说明xy的lca至浅是x_father,而depth(a)<=depth(x_father)&&a!=x_father => depth(a)<depth(x_father),所以xy的lca不应该是a)

2、x_father和y_father不同:那只要depth(a)<depth(x_father)&&depth(a)<depth(y_father)就好了。

讨论完后如果正确,那就并查集那样并起来,继续搞。


中间有矛盾就是wrong,没矛盾的话,根据并的过程就能给出一个可行解,maybe right了。

The classification of agricultural products is a system used to group different types of crops and livestock based on their characteristics, usage, and market value. This system is important for farmers, traders, and governments to understand the agricultural sector and to make informed decisions about production, distribution, and trade. Here are some key points about the classification of agricultural products: 1. The classification of agricultural products varies by country and region, depending on local conditions, traditions, and regulations. 2. In general, agricultural products can be classified into two main categories: crops and livestock. 3. Crops can be further classified into two groups: food crops and non-food crops. Food crops are those that are grown for human consumption, such as grains, vegetables, fruits, and nuts. Non-food crops are those that are grown for other purposes, such as fiber, fuel, or industrial uses. 4. Livestock can be classified into four groups: meat animals, dairy animals, poultry, and other animals. Meat animals include cattle, sheep, pigs, and goats. Dairy animals include cows, goats, and sheep. Poultry include chickens, turkeys, ducks, and geese. Other animals include horses, rabbits, and bees. 5. Within each group, there may be further subcategories based on specific characteristics such as breed, quality, or market value. 6. The classification of agricultural products is important for trade and export regulations, as well as for government policies related to food security, rural development, and environmental sustainability. Overall, the classification of agricultural products is a complex system that reflects the diversity and complexity of the agricultural sector. Understanding this system is important for anyone involved in agriculture, from farmers to policymakers to consumers.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值