博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj-1056-IMMEDIATE DECODABILITY(字典)
阅读量:6329 次
发布时间:2019-06-22

本文共 1971 字,大约阅读时间需要 6 分钟。

Description

An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at least one bit and no more than ten bits, and that each set has at least two codes and no more than eight.
Examples: Assume an alphabet that has symbols {A, B, C, D}
The following code is immediately decodable:
A:01 B:10 C:0010 D:0000
but this one is not:
A:01 B:10 C:010 D:0000 (Note that A is a prefix of C)

Input

Write a program that accepts as input a series of groups of records from standard input. Each record in a group contains a collection of zeroes and ones representing a binary code for a different symbol. Each group is followed by a single separator record containing a single 9; the separator records are not part of the group. Each group is independent of other groups; the codes in one group are not related to codes in any other group (that is, each group is to be processed independently).

Output

For each group, your program should determine whether the codes in that group are immediately decodable, and should print a single output line giving the group number and stating whether the group is, or is not, immediately decodable.

Sample Input

0110001000009011001000009

Sample Output

Set 1 is immediately decodableSet 2 is not immediately decodable 题目大意: 就是输多组0 1数据,任意一组数据不能成为另一种的前缀;

一组符号的编码是立即可解码的如果没有前缀的代码一个符号代码的另一个象征。我们将假定这个问题,所有的二进制代码,没有两个编码在一组编码是相同的,每个代码至少有一个,不超过十位,每组至少有两个编码和不超过8个。

 

例子:假设一个字母,符号{ A,B,C,D }

 

下面的代码是立即可解码

#include
#include
#include
using namespace std;int main(){ string str[10]; int i=0; int y=1,w=0; while(cin>>str[i]) { if(str[i]=="9") { i=0; w++; if(y==1)cout<<"Set "<
<<" is immediately decodable"<

  

 

转载地址:http://viboa.baihongyu.com/

你可能感兴趣的文章
linux(Ubuntu/Centos) iproute 路由IP地址等命令集合,查看端口链接
查看>>
php 常用的JS
查看>>
text-overflow
查看>>
python之路之面向对象3
查看>>
codeforces 940D 比赛总结
查看>>
ulua
查看>>
面向对象与面向过程区别
查看>>
D3js-实现图形拖拽及双击恢复
查看>>
示例可重用的web component方式组织angular应用模块
查看>>
【RS】如何从USGS上下载LANDSAT数据
查看>>
8张图理解Java(转)
查看>>
JVM
查看>>
Zend-MVC事件
查看>>
sql 截取字符串
查看>>
【札记】设计的五个原则
查看>>
java枚举使用详解
查看>>
linux的bash与sh的区别
查看>>
天线的安装
查看>>
vim 加密文件
查看>>
关于jetbrains系列产品2018.1.5以后的使用(crack)方法
查看>>