BZOJ 2344: [Baltic2011]Icecream 暴力

本文解析了[Baltic2011]Icecream算法竞赛题目,探讨了如何计算在有限制条件下的冰淇淋组合数。具体限制为某些冰淇淋不能同时选择,而目标是找出所有合法的三明治冰淇淋组合。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2344: [Baltic2011]Icecream

Time Limit: 1 Sec  Memory Limit: 256 MB
Submit: 279  Solved: 218
[Submit][Status][Discuss]

Description

现在有N种冰淇淋,TZ要吃他们。
由于TZ食量有限,他等下还要去吃若菜,所以他只吃3个。
然而因为TZ比较神,所以他觉得某两个冰淇淋不能一起吃。
一共有M组不能一起吃的冰淇淋。
TZ可以瞬间算出一共有多少中吃法([1,2,3]和[2,1,3]是同种),
你能吗?

n<=200,m<=10000

Input

Output

Sample Input

5 3
1 2
3 4
1 3

Sample Output

3

HINT

There are 5 flavors and 3 impossible pairings. Flavor 1 should be combined with neither flavor 2 nor
flavor 3, and flavor 3 also should not be chosen together with flavor 4. Only 3 ways to choose three
different flavors remain: (1 4 5), (2 3 5), and (2 4 5).


没有题解

我来造福人类


#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<map>
#include<set>
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
void print(int x)
{if(x<0)putchar('-'),x=-x;if(x>=10)print(x/10);putchar(x%10+'0');}

const int N=210;

bool mp[N][N];

int main()
{
	int n=read(),m=read();
	register int i,j,k,x,y;
	for(i=1;i<=m;++i)x=read(),y=read(),mp[x][y]=mp[y][x]=1;
		int ans=0;
	for(i=1;i<=n;++i)
		for(j=i+1;j<=n;++j)
			for(k=j+1;k<=n;++k)
				if(!mp[i][j]&&!mp[i][k]&&!mp[j][k])
					ans++;
	cout<<ans<<endl;
}
/*
5 3
1 2
3 4
1 3

3
*/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值