HDU-1305-Immediate Decodability
来源:互联网 发布:java finalize 编辑:程序博客网 时间:2024/05/22 05:25
HDU-1305-Immediate Decodability
http://acm.hdu.edu.cn/showproblem.php?pid=1305
字典树水题,判断前缀
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;struct node{int count;node *childs[2];node(){count=0;for(int i=0;i<2;i++)childs[i]=NULL;}};node *root,*current,*newnode;int flag;void insert(char *str){int i,m;current=root;for(i=0;i<strlen(str);i++){m=str[i]-'0';if(current->childs[m]!=NULL){current=current->childs[m]; if(i==strlen(str)-1||current->count==1){flag=0;break;}}else{newnode=new node;current->childs[m]=newnode;current=newnode;}}current->count=1;}void del(node *head){for(int i=0;i<2;i++)if(head->childs[i]!=NULL)del(head->childs[i]);delete(head);}int main(){int cas=1;char str[15];while(scanf("%s",str)!=EOF){flag=1;root=new node;insert(str);while(scanf("%s",str),strcmp(str,"9")){if(!flag)continue;insert(str);}if(!flag)printf("Set %d is not immediately decodable\n",cas++);elseprintf("Set %d is immediately decodable\n",cas++);del(root);}return 0;}
- HDU-1305-Immediate Decodability
- hdu 1305 Immediate Decodability
- hdu 1305 Immediate Decodability
- HDU-1305 Immediate Decodability
- hdu-1305 Immediate Decodability
- HDU 1305 Immediate Decodability
- hdu 1305 Immediate Decodability
- hdu 1305 Immediate Decodability
- HDU 1305 Immediate Decodability
- hdu-1305-Immediate Decodability
- HDU 1305:Immediate Decodability
- HDU 1305 Immediate Decodability
- HDU 1305 Immediate Decodability(二叉树)
- 杭电 hdu 1305 Immediate Decodability
- hdu 1305 Immediate Decodability(字典树)
- Hdu 1305 Immediate Decodability 字典树
- hdu 1305 Immediate Decodability(Trie树)
- 【水题-前缀码】HDU 1305 Immediate Decodability
- 使用libevent编写linux服务
- Dokan(Windows FUSE)学习笔记
- hibernate3.0 中文查询时数组越界
- JavaScript 变量声明
- Connectify: 同时使用多个网络的带宽
- HDU-1305-Immediate Decodability
- HDU1102 Constructing Roads
- 删繁就简
- ibatis 配置文件
- Android 动画
- [Android1.5]TextView跑马灯效果
- thinkphp视频目录
- [留着备用]ASP.NET动态菜单生成通用方法
- 导入别人的项目时,工程中不自动生成Android Dependencies的解决方式