AGC 016 E Poor Turkeys

Problem Statement

There are N turkeys. We number them from 1 through N.

M men will visit here one by one. The i-th man to visit will take the following action:

  • If both turkeys xi and yi are alive: selects one of them with equal probability, then eats it.
  • If either turkey xi or yi is alive (but not both): eats the alive one.
  • If neither turkey xi nor yi is alive: does nothing.

Find the number of pairs (ij) (1≤i<jN) such that the following condition is held:

  • The probability of both turkeys i and j being alive after all the men took actions, is greater than 0.

Constraints

  • 2≤N≤400
  • 1≤M≤105
  • 1≤xi<yiN


我有个乱搞做法,和题解略微不同,感性上看很有道理,在这里mark一下,如果哪位能叉掉请在评论区告知我。

设bz[i][j]∈{0,1}表示i是否可能与j同时存活。

易于发现这个bz是有传递性的,即如果bz[x][y]=0,bz[y][z]=0,那么一定有bz[x][z]=0

每次的连边(x,y)相当于是令bz[x][y]=0,那么我们传递一次bz数组。

特殊地,如果在这次(x,y)之前,已经有bz[x][y]=0,那么这次以后,x和y必定都死了,die[x]=die[y]=1。

最后如果数对(i,j)满足die[x]=0 and die[y]=0 and bz[x][y]=1,就满足条件。

复杂度O(nm+n^2)

 

贴一下官方题解:

Editorial

转载于:https://www.cnblogs.com/lyd729/p/9221081.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值