1590: [Usaco2008 Dec]Secret Message 秘密信息
1590: [Usaco2008 Dec]Secret Message 秘密信息
Time Limit: 5 Sec Memory Limit: 32 MB
Submit: 209 Solved: 143
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
3 0 1 0
1 1
3 1 0 0
3 1 1 0
1 0
1 1
2 0 1
5 0 1 0 0 1
2 1 1
INPUT DETAILS:
Four messages; five codewords.
The intercepted messages start with 010, 1, 100, and 110.
The possible codewords start with 0, 1, 01, 01001, and 11.
Sample Output
3
1
1
2
HINT
0 matches only 010: 1 match 1 matches 1, 100, and 110: 3 matches 01 matches only 010: 1 match 01001 matches 010: 1 match 11 matches 1 and 110: 2 matches
Source
- type
- point=^node;
- node=record
- tt,ex:longint;
- next:array[..] of point;
- end;
- var
- i,j,k,l,m,n:longint;
- head:point;
- s1:ansistring;
- function newp:point;
- var p:point;
- begin
- new(p);p^.tt:=;p^.ex:=;
- p^.next[]:=nil;p^.next[]:=nil;
- exit(p);
- end;
- procedure insert(s1:ansistring);
- var i:longint;p:point;
- begin
- p:=head;
- for i:= to length(s1) do
- begin
- if p^.next[ord(s1[i])-]=nil then
- p^.next[ord(s1[i])-]:=newp;
- p:=p^.next[ord(s1[i])-];
- inc(p^.tt);
- end;
- inc(p^.ex);
- end;
- function num(s1:ansistring):longint;
- var i,j,k,l:longint;p:point;
- begin
- p:=head;j:=;k:=;l:=;
- for i:= to length(s1) do
- begin
- if p^.next[ord(s1[i])-]=nil then break;
- p:=p^.next[ord(s1[i])-];
- k:=k+j;
- j:=p^.ex;
- l:=i;
- end;
- if l<>i then num:=k+j else num:=k+p^.tt;
- end;
- begin
- readln(n,m);
- head:=newp;
- for i:= to n do
- begin
- read(l);s1:='';
- for j:= to l do
- begin
- read(k);
- s1:=s1+chr(+k);
- end;
- readln;
- insert(s1);
- end;
- for i:= to m do
- begin
- read(l);s1:='';
- for j:= to l do
- begin
- read(k);
- s1:=s1+chr(+k);
- end;
- readln;
- writeln(num(s1));
- end;
- readln;
- end.
1590: [Usaco2008 Dec]Secret Message 秘密信息的更多相关文章
- bzoj 1590: [Usaco2008 Dec]Secret Message 秘密信息
1590: [Usaco2008 Dec]Secret Message 秘密信息 Description 贝茜正在领导奶牛们逃跑.为了联络,奶牛们互相发送秘密信息. 信息是二进制的,共 ...
- [Usaco2008 Dec]Secret Message 秘密信息
2794: [Usaco2008 Dec]Secret Message 秘密信息 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 7 Solved: 3 ...
- BZOJ1590:[Usaco2008 Dec]Secret Message秘密信息
浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:https://lydsy.com/JudgeOnline/problem ...
- BZOJ1590 [Usaco2008 Dec]Secret Message 秘密信息
建立一颗trie树,记录下来每个点以它为结尾的字符串的个数cnt,和它的子树内有多少字符串size 于是查询的时候就只需要把沿途的cnt加起来,再加上最后的size就好了 /************* ...
- [BZOJ1590] [Usaco2008 Dec]Secret Message 秘密信息(字典树)
传送门 看到前缀就要想到字典树! 看到前缀就要想到字典树! 看到前缀就要想到字典树! #include <cstdio> #include <iostream> #define ...
- 【Trie】Secret Message 秘密信息
[题目链接]: https://loj.ac/problem/10054 [题意] 我认为这个题目最难的是题意: 其实分了两种情况: 1.如果当前文本串匹配不完,那么答案的是:匹配过程中遇到的模式串结 ...
- 洛谷P2922 [USACO008DEC] 秘密消息Secret Message [Trie树]
洛谷传送门,BZOJ传送门 秘密消息Secret Message Description 贝茜正在领导奶牛们逃跑.为了联络,奶牛们互相发送秘密信息. 信息是二进制的,共有M(1≤M≤5 ...
- [USACO08DEC] 秘密消息Secret Message
题目描述 Bessie is leading the cows in an attempt to escape! To do this, the cows are sending secret bin ...
- 「USACO08DEC」「LuoguP2922」秘密消息Secret Message(AC自动机
题目描述 Bessie is leading the cows in an attempt to escape! To do this, the cows are sending secret bin ...
随机推荐
- ORACLE Postgresql中文排序
当我们order排序不能够实现我们想要的内容时候,尝试一下NLSSORT这个函数吧 他不仅仅按照姓氏排序,名也会排序: nls_param用于指定语言特征,格式为nls_sort = sor ...
- python如何安装模块
1.从 https://pypi.python.org/pypi/XXXX 下载压缩包 2.解压所下载的压缩包 3.CD到解压目录,执行 sudo python setup.py install
- 【Unity3d游戏开发】游戏中的贝塞尔曲线以及其在Unity中的实现
RT,马三最近在参与一款足球游戏的开发,其中涉及到足球的各种运动轨迹和路径,比如射门的轨迹,高吊球,香蕉球的轨迹.最早的版本中马三是使用物理引擎加力的方式实现的足球各种运动,后来的版本中使用了根据物理 ...
- Bootstrap入门(三十)JS插件7:警告框
Bootstrap入门(三十)JS插件7:警告框 通过这个插件可以为警告信息添加点击以及消失的功能. 当使用一个.close按钮,它必须是第一个子元素.alert-dismissible,并没有文字内 ...
- iOS页面间传值的五种方式总结(Delegate/NSNotification/Block/NSUserDefault/单例)
iOS页面间传值的方式(Delegate/NSNotification/Block/NSUserDefault/单例) iOS页面间传值的方式(NSUserDefault/Delegate/NSNot ...
- ArcGIS API for JavaScript 4.2学习笔记[5] 官方API大章节概述与内容转译
内容如上,截图自ESRI官网,连接:ArcGIS API for JavaScript 4.2 [Get Started] 类似于绪论一样的东西,抽取了最需要关注的几个例子.如:加载Map和View, ...
- WinForm 进程、线程
一.进程 进程是一个具有独立功能的程序关于某个数据集合的一次运行活动. 它可以申请和拥有系统资源,是一个动态的概念,是一个活动的实体. Process 类,用来操作进程. 命名空间:using Sys ...
- 关于a.b和a[b]的区别
在写代码的过程中,我们经常可以看到a.b或啊a[b],但是他们有什么区别呢: 简单说一下吧,有自己的还用群友的大力支持! 在js的对象中 var arr = {a:"b",b:&q ...
- 关于j2ee工程发布到was上后,部分更新,例修改web.xml配置文件不起作用的原因解析【转】
在WAS中,应用的配置是从config/cells....目录下读取:而资源从/installedApps目录下读取 故当配置文件(例web.xml)发生改变时,只更新应用程序资源文件/install ...
- java 多线程之卖票两种方式
1.通过extends Thread /* 需求:简单的卖票,多个窗口同时买票 (共用资源) 创建线程的第二种方式:实现Runnable接口 步骤: 1,定义类实现Runnable接口 2,覆盖/重写 ...