POJ 1830(位运算+双向DFS)
来源:互联网 发布:京东商城和淘宝销售额 编辑:程序博客网 时间:2024/05/17 01:01
此题也可用GE做,可是我不会矩阵乘法……
Program P1830;const maxn=28; maxf=100007; none=-2139062144;var ans,tt,n,i,j,s,t,mid:longint; b:array[1..29] of longint; h,num:array[0..maxf] of longint;function hash(x:longint):longint;var i,j:longint;begin hash:=x mod maxf; while (num[hash]<>x) and (num[hash]<>none) do begin hash:=(hash+1) mod maxf; end; num[hash]:=x; exit(hash);end;procedure dfs(x,l:longint);var i,j:longint;begin if l=mid+1 then begin inc(h[hash(x)]); exit; end; for i:=l to mid do dfs(x xor b[i],i+1); dfs(x,mid+1);end;procedure find(x,l:longint);var i,j:longint;begin if l=n+1 then begin inc(ans,h[hash(x)]); exit; end; for i:=l to n do find(x xor b[i],i+1); find(x,n+1);end;begin read(tt); while (tt>0) do begin ans:=0; fillchar(b,sizeof(b),0); fillchar(num,sizeof(num),128); fillchar(h,sizeof(h),0); read(n); s:=0; for i:=1 to n do begin read(j); if j=1 then inc(s,1 shl (i-1)); end; t:=0; for i:=1 to n do begin read(j); if j=1 then inc(t,1 shl (i-1)); end; while (true) do begin read(i,j); if (i=0) and (j=0) then break; inc(b[i],1 shl (j-1)); end; for i:=1 to n do inc(b[i],1 shl (i-1)); mid:=n shr 1; dfs(s,1); find(t,mid+1); if ans=0 then writeln('Oh,it''s impossible~!!') else writeln(ans); dec(tt); end;end.
- POJ 1830(位运算+双向DFS)
- POJ 1753(DFS+枚举||BFS+位运算)
- POJ 1753 Flip Game ------- DFS & 位运算 .
- POJ 1753 - 位运算(异或)+BFS / DFS+枚举
- POJ 3748 位操作(位运算)
- poj 1186 方程的解数 (hash+双向dfs)
- 八皇后 位运算dfs
- poj1143 DP+dfs+位运算- -
- hdu 5014(dfs + 位运算)
- UVA-818 dfs + 位运算
- POJ 1222 (数组模拟位运算)
- POJ 2965详解 (bfs、位运算)
- POJ-2965(BFS + 位运算)
- POJ Flip Game(BFS + 位运算)
- poj 2453 位运算
- POJ 2443 位运算
- poj_1753 Flip Game(dfs+枚举)/(bfs+位运算)
- **POJ1632 Vase collection ACM解题报告(位运算+DFS)
- 明年的七夕,你还记得我吗
- 使用PDFBox处理PDF文档
- E:Could not open lock file /var/lib/dpkg/lock
- iPhone开发之深入浅出Object-C之消息
- 防止同一个账户异地登陆AND多用户同时登陆操作互不干扰
- POJ 1830(位运算+双向DFS)
- ANT详解
- 上次同学说写搜索表单号要显示请输入,但是点击输入就点搜索,输入框的值是空的,点击输入框表单号消失,自己试了下
- oracle数据库锁解除方法之一
- 采用多播传送FIX行情数据的推荐方案
- 制作手札---RPG是怎样做成的 (二)
- vmware-view-client for ubuntu
- live555 分析
- fedora修改密码