[agc016e]Poor Turkeys

前言

感觉不是很难。
虽然一开始想着是废掉的缩点。
仔细想想又没有这样实现的道理。

题意

n个人。
有m个按时间的暗杀行动。
第i次请杀手杀ai和bi,如果都活着杀手按照心情杀一个,都死了就不杀,只活一个杀死活的那个。
问m次暗杀过后有多少对人可能都存活?

题解

考虑按时间倒着来。
如果你想要x存活,每当遇到与x有关的,又会出现新的应该存活的。
我们称为存活集合。
每次一个两端均不在存活集合的无视,都在则集合内均不能存活,只有一端在那么另一端也加入集合。
如果x和y都要存活,显然x和y分别都有可能存活且存活集合交集为空(有交的话一定有一个被杀)。
那么就很容易了。

#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=400+10,maxm=100000+10;
int a[maxm],b[maxm];
bool bz[maxn][maxn],p[maxn],czy;
int i,j,k,l,r,t,x,y,n,m,ans;
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m) scanf("%d%d",&a[i],&b[i]);
    fo(i,1,n){
        p[i]=1;
        bz[i][i]=1;
        fd(j,m,1){
            x=a[j];y=b[j];
            if (!bz[i][x]&&!bz[i][y]) continue;
            if (bz[i][x]&&bz[i][y]){
                p[i]=0;
                break;
            }
            bz[i][x]=bz[i][y]=1;
        }
    }
    fo(i,1,n-1)
        fo(j,i+1,n)
            if (p[i]&&p[j]){
                czy=1;
                fo(k,1,n)
                    if (bz[i][k]&&bz[j][k]){
                        czy=0;
                        break;
                    }
                if (czy) ans++;
            }
    printf("%d\n",ans);
}
  • 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、付费专栏及课程。

余额充值