Hdu 5765 Bonds
来源:互联网 发布:传奇霸业翅膀升级数据 编辑:程序博客网 时间:2024/05/01 09:10
丢链接
具体的,
首先找一个
显然
位运算大法好~
#include<bits/stdc++.h>using namespace std;const int bit = 22;const int maxn = 1<<bit;int l[bit*bit],r[bit*bit];int edge[bit];int rev[maxn];int cnt[maxn];int lowbit(int x){ return x & (-x);}bool check(int S){ int done = 0; int did = lowbit(S); while(did != done){ int st = rev[lowbit(did ^ done)]; done |= 1<<st; did |= edge[st] & S; } return done == S;}int main(){ int T; scanf("%d",&T); int n,m; int icase = 1; memset(rev,-1,sizeof(rev)); for(int i=0;i<bit;i++) rev[1<<i] = i; while(T-- && ~scanf("%d %d",&n,&m)){ memset(edge,0,sizeof(edge)); memset(cnt,0,sizeof(cnt)); for(int i=0;i<m;i++){ scanf("%d %d",&l[i],&r[i]); edge[l[i]] |= 1<<r[i]; edge[r[i]] |= 1<<l[i]; } int bnd = (1<<n) - 1; int all = 0; for(int i=1;i<bnd;i++){ if((i&1) && check(i) && check(bnd ^ i)){ cnt[i]++,cnt[bnd^i]++; all++; } } for(int i=1;i<=bnd;i<<=1){ for(int j=0;j<=bnd;j++){ if(i&j) cnt[i^j] += cnt[j]; } } printf("Case #%d:",icase++); for(int i=0;i<m;i++){ printf(" %d",all - cnt[(1<<l[i])|(1<<r[i])]); } puts(""); } return 0;
0 0
- HDU 5765 Bonds
- Hdu 5765 Bonds
- hdu 5765 Bonds 状压
- Hdu-5765 Bonds(状压)
- HDU 5765 Bonds (二进制技巧)
- Hdu 5765 Bonds(高维前缀和)
- 【HDU 5765】Bonds(进制运算妙用)
- HDU 5765 Bonds(bfs+高维前缀和)
- hdoj 5765 Bonds
- coupon bonds
- 5 Basic Things To Know About Bonds
- android UiAutomator了解源码解决控件bonds[0,0]无法点击
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- hdoj 5773 <变相LIS>
- Rails 中的持久化框架 Active recored
- poj 1789 Truck History
- Android Studio does not detect .aidl files
- Python随学随记(4)
- Hdu 5765 Bonds
- 人生十难
- vs2013编译FFMPEG. 连接错误问题.
- Java设计模式--单例模式
- ubuntu 下如何以root身份登录
- 二分+dp,在一个地方上卡了2小时
- 机器学习领域的五大流派
- 有两个32bit的数A、B,使用下面方式得到32bit的数C、D。哪一种可以使用C、D得到A、B的值?
- 多重背包模板