HDU 5763 Another Meaning(多校4)

Android 12,通过JNI写framebuff实现白板书写加速 Android 书写加速 阅读详情

Another Meaning

Problem Description
As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. 
Today, ?? is chating with MeiZi online, MeiZi sends a sentence A to ??. ?? is so smart that he knows the word B in the sentence has two meanings. He wants to know how many kinds of meanings MeiZi can express.
 

Input
The first line of the input gives the number of test cases T; T test cases follow.
Each test case contains two strings A and B, A means the sentence MeiZi sends to ??, B means the word B which has two menaings. string only contains lowercase letters.

Limits
T <= 30
|A| <= 100000
|B| <= |A|

 

Output
For each test case, output one line containing “Case #x: y” (without quotes) , where x is the test case number (starting from 1) and y is the number of the different meaning of this sentence may be. Since this number may be quite large, you should output the answer modulo 1000000007.
 

Sample Input
4 hehehe hehe woquxizaolehehe woquxizaole hehehehe hehe owoadiuhzgneninougur iehiehieh
 

Sample Output
Case #1: 3 Case #2: 2 Case #3: 5 Case #4: 1
Hint
In the first case, “ hehehe” can have 3 meaings: “*he”, “he*”, “hehehe”. In the third case, “hehehehe” can have 5 meaings: “*hehe”, “he*he”, “hehe*”, “**”, “hehehehe”.
题意:
给定两个字符串,问第二个串在第一个串中可以最多可以表现多多少种不同的意思
题解:
直接上KMP找出对于第一个字符串的Pos位置的前缀和第二个字符串相同的所有位置,直接dp就可以了,听说数据很水的样子。
HDUOJ不能用next关键字当做数组名,导致CE一发,以后记住了。
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <iomanip>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define LL long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int Mod = 1000000007;
const double esp = 1e-6;
const double PI = 3.1415926535898;
const int INF = 0x3f3f3f3f;
using namespace std;

char s[100005],t[100005];
bool vis[100005];
int Next[100005];
LL dp[100005];

void getnext(){
    int i=0,j=-1;
    Next[0]=-1;
    while(t[i]!='\0'){
        if(j==-1||t[i]==t[j]){
            i++;
            j++;
            Next[i]=j;
        }
        else{
            j=Next[j];
        }
    }
}

void kmp(){
    memset(vis,false,sizeof(vis));
    int i = 0,j = 0;
    getnext();
    int len1=strlen(s),len2=strlen(t);
    while(i<len1){
        if(j==-1||s[i]==t[j]){
            i++;
            j++;
        }
        else
            j=Next[j];
        if(j>=len2){
             vis[i] = true;
             j = Next[j];
        }
    }
}
int main(){
    int n , z = 1;
    scanf("%d%*c",&n);
    while(n--){
        gets(s);
        gets(t);
        kmp();
        int len = strlen(s);
        int len2  = strlen(t);
        dp[0] = 1;
        for(int i=1;i<=len;i++){
            dp[i] = dp[i-1];
            if(vis[i]){
                dp[i] = (dp[i]+dp[i-len2])%Mod;
            }
        }
        printf("Case #%d: %lld\n",z++,dp[len]);
    }
    return 0;
}


【DeepSeek R1构建本地RAG知识库】数据结构化清洗-知识图谱制作、使用、dify集成 本文探讨了在构建本地RAG(Retrieval-Augmented Generation)系统时,如何通过引入知识图谱来增强系统的知识理解能力。传统的向量数据库和嵌入模型虽然能处理语义匹配,但无法有效捕捉知识间的关联性。知识图谱通过“实体-关系-属性”的结构化表示,能够更好地支持推理、推荐和多跳问答等高级功能。文章详细介绍了知识图谱的基本概念、制作思路,以及如何使用Neo4j图数据库进行知识图谱的构建和查询。通过实例展示了从PDF文件解析到知识图谱入库的全过程,强调了知识图谱在提升RAG系统性能中的重要作用 阅读详情

相关推荐

DPO(Direct Preference Optimization)实战全流程指南

《DPO实战全流程指南》摘要 本文提供了端到端的DPO(直接偏好优化)实战方案,包含数据准备、模型训练、评估部署全流程。核心内容包括: 数据构建:推荐UltraFeedback等高质量数据集,提供数据预处理代码 训练配置:基于HuggingFace TRL库的DPO实现,详解beta值等关键参数调优 工业优化:显存节省技巧(LoRA、梯度检查点)、领域自适应方法和在线学习架构 效果评估:量化对比显示DPO可降低86%有害回复率,提升24%用户满意度 常见问题:针对灾难性遗忘、过度安全化等问题给出解决方案 附

技术引领业务创新 1467

解题报告:HDU 5763

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

HyJoker的博客 1010

Windows下MMdetection3D保姆级安装指南(含CUDA和PyTorch版本避坑)

本文提供Windows平台下MMdetection3D的完整安装指南,重点解决CUDA与PyTorch版本匹配问题。从环境准备到关键组件安装,详细介绍了CUDA Toolkit选择策略、PyTorch精准安装步骤,以及MM系列组件的安装顺序和常见错误解决方案,帮助用户顺利完成3D目标检测环境的配置。

weixin_42628941的博客 490

(HDU - 5763)Another Meaning

(HDU - 5763)Another Meaning As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. Today, ?? is chating with MeiZi online, MeiZi se

The wind of freedom blows 479

VMD分子可视化实战:5个隐藏技巧让你的科研图像秒变顶刊级别

本文深入探讨了VMD分子可视化软件在科研图像美化中的5个高阶技巧,旨在帮助研究者将分子结构图提升至顶刊级别。内容涵盖原子色彩与材质的艺术化定制、沉浸式分子环境构建、专业构图与视角控制、数据驱动的动态可视化以及自动化工作流建立,通过精细的色彩映射、光照调整、周期性边界展示和脚本自动化,显著增强图像的科学叙事性与视觉冲击力。

weixin_29240343的博客 421

安装openclaw时出现node.exe : npm error code EIDLETIMEOUT的解决方案

本文主要介绍了安装openclaw时出现node.exe : npm error code EIDLETIMEOUT的解决方案,希望能对学习使用openclaw的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 11万+

HDU 5763 Another Meaning

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

Occult 505

Python爬虫实战:逆向工程与异步处理攻克Pinterest无限滚动瀑布流

我们将从零开始,逐步分析其数据接口,构建一个功能完整的爬虫,并深入探讨反爬虫策略的应对、性能优化以及数据存储等高级主题。: 在实际爬取中,你需要先访问一次Pinterest主页,获取初始的Cookie和CSRF Token,然后再发起API请求。: Python爬虫,Pinterest,无限滚动,瀑布流,异步IO,httpx,逆向工程,API接口,动态内容,反爬虫。你会很快发现一些关键的请求模式。:页面初始加载有限内容,随着用户滚动,新的图片块通过AJAX动态加载,实现“永无止境”的浏览。

2201_76125261的博客 551

(HDU 5763)Another Meaning <KMP + dp> 多校训练4

Another Meaning As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. Today, ?? is chating with MeiZi online, MeiZi sen

STILLxjy 568

OpenClaw实战五|企业文档AI助理:对接内部知识库+自动答疑+文档生成,员工自助查资料零等待

企业最大的隐性成本,不是设备、不是房租,而是内部知识的混乱与流失。OpenClaw企业文档AI助理,本质是给企业做了一个7×24小时在线、永不疲倦、精准无误、自动更新的内部知识管家。它不替代HR、行政、IT,而是把他们从无穷无尽的重复问答、机械文档编写里解放出来,去做更有价值的管理、服务、优化工作。对中小企业来说,不用买昂贵的知识库系统、不用招开发、不用做复杂集成,一台私有化服务器,两天就能落地,性价比拉满。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 144

HyperLynx(十八)DDR(一)DDR简介和DDR的数据仿真

LVTTL电平为单端信号,而SSTL电平本质上是差分对,其实现机制是将信号与参考电平Vref组成差分对进行比较,如图所示,VIH和VIL各有一个交流参数AC和直流参数DC,信号第一次越过AC门限的时刻,作为时序计算的参考点,此后只要信号保持DC门限内,逻辑状态保持不变,这种设计减小了噪声、振铃等对于信号质量的影响。经过调整后,控制器在发送颗粒1的DQS后,延时1ns再发送颗粒2的DQS,则颗粒1在1ns后收到对齐的DQS和CLK,颗粒2在2ns后收到对齐的DQS和CLK,从而满足了时序关系。

小幽余生不加糖 7676

【字符串 Hash】【DP】 HDU - 5763 Another Meaning【串二可用第二种意思替换,问串一这句话可能有几种含义】

【字符串 Hash】【DP】 HDU - 5763 Another Meaning【串s2可用第二种意思替换,问串一这句话可能有几种含义】 As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse...

Floraqiu的博客 423

130、NPU的仿真测试:使用Gem5进行全系统仿真

这篇文章摘要(149字): 本文分享了使用Gem5全系统仿真器验证NPU设计的实践经验。作者通过搭建自定义NPU模型并集成到Gem5系统中,实现了CPU-NPU-内存协同仿真。关键点包括:1) 使用SimObject机制构建可配置的NPU模型;2) 合理配置IO和内存总线避免访问冲突;3) 开发Linux驱动实现CPU与NPU通信;4) 利用Gem5调试功能监控内部状态。相比RTL仿真和FPGA验证,该方法能快速验证微架构设计并定位系统级问题,有效减少了流片风险。文章特别强调了时钟域配置、总线仲裁、对齐访问

m0_50546716的博客 122

hdu5763 多校4 Another Meaning【kmp+dp】

题意: 给一个字符串和一个单词,问单词在串中的组合数。思路: 看到题想到了dp+kmp,推了一个别扭的转移方程,结果因为脑抽没过。。。 回头看了题解,比自己推得简单好多,而且发现不用kmp优化也不会超时。dp[i] 表示0-i串的组合数, dp[0] = 1, dp[i] = dp[i-1], (i-len+1, i)串匹配时 dp[i] += dp[i-len];题目传送门#incl

lh的博客 344

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

2016多校联赛4A Another Meaning(hdu 5763)

Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 266    Accepted Submission(s): 114 Problem Description As is known

overload1997 402

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

2016多校训练Contest4: 1001 Another Meaning hdu5763

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

lqybzx的专栏 463

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

【动态规划】【KMP】HDU 5763 Another Meaning

题目链接:   http://acm.hdu.edu.cn/showproblem.php?pid=5763 题目大意:   T组数据,给两个字符串s1,s2(len<=100000),s2可以被解读成2种意思,问s1可以解读成几种意思(mod 1000000007)。 题目思路:   【动态规划】【KMP】   题目有点绕,看看样例就懂了。其实不用KMP直接用subs...

PHILIP0917的博客 185

(2016多校联赛)hdu 5763 Another Meaning

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 题目大意: 给你两个字符串a,b,其中b字符串有两种意思,a串中也许有包含b串,问a串总共能组合出几种意思。 解题思路: 很明确的,这种题可以用DP。 我们令dp[i]为第i位之前的串共有多少种意思,这样答案输出  dp[ a串的长度 ]  即可。 首先,到第

霞之丘诗羽的博客 1743

HDU5763 Another Meaning

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 【题意】给定A,B两个字符串,B串有两个含义,问A串可能有几个含义。 【分析】先用KMP求出B串在A串中的所有位置。假定构成B串需要n个字符,position[i]表示B串在A串中第i+1次出现的位置,dp[i]表示从串头到position[i],A串可能的含义数。那么对于j

dDarkdawn的博客 474

hdu 5763 Another Meaning(2016 Multi-University Training Contest 4——dp+kmp)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 802    Accepted

若忆_star 1153

hdu_5763_Another Meaning(dp)

题目链接:hdu_5763_Another Meaning 题意: 一个文本串A,一个模式串B,如果文本串含有模式串B,那么就能组合成多种意思,如下: In the first case, “ hehehe” can have 3 meaings: “*he”, “he*”, “hehehe”. In the third case, “hehehehe” can have 5 meaing...

weixin_30817749的博客 137

HDU 5763 Another Meaning 多校赛 (DP + KMP)

Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1111    Accepted Submission(s): 518 Problem Description As is known

qq_18661257的专栏 623

HDU 5763 Another Meaning (kmp + dp)

Another Meaning 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also mean...

weixin_30839881的博客 101

hdu 5763 Another Meaning

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, MeiZ

zoro_n的博客 360

hdu5763 Another Meaning (DP+KMP)

思路: 令dp[i]表示到i结尾的字符串可以表示的不同含义数,那么考虑两种转移: 末尾不替换含义:dp[i - 1] 末尾替换含义:dp[i - |B|]  (A.substr(i - |B| + 1,|B|) = B) 那么对于末尾替换含义的转移,需要快速判断BB能不能和当前位置的后缀匹配,kmp或者hash判断即可。 复杂度:O(N) #include

围巾的ACM博客 879

hdu 5763 Another Meaning KMP+DP(多校)

题意: 一句话可能有两个意思,给出两个字符串A,B。B是双重意思的字符串,问A这个字符串可有几种意思?也就是说,把B串在A中替换成*,一共可以构造出几种? 例: hehehehe hehe 答案是5 分析: 这题当时是我做的,第一次next数组编译错误QAQ,第二次A了。 思路是:先KMP求出B串在A串中出现的位置,然后就想着用dp了。由于在A串中B串...

141
上一篇: HDU 5774 Where Amazing Happens(多校4)
下一篇: Calculate S(n) (规律题)
哆啦AC梦
博客等级 码龄12年 13粉丝 87原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值