【HDOJ】5918 Sequence I CCPC2016 长春

2019年7月28日解决战网BLZBNTBNA00000005BLZBNTBNA00000006BLZBNTBTS0000005DBLZBNTBTS0000004A 007D0 008A4 00840 Blizzard—Battle.net—2019年7月28解决战网BLZBNTBNA00000005BLZBNTBNA00000006BLZBNTBTS0000005DBLZBNTBTS0000004A 007D0 008A4 008402019年7月28日再次更新写在前面■■■ 排查网路问题 ■■■■■■ 排查电脑自身问题 ■■■■尝试重置internet设置■网络的设置和防火墙规则■如果还是不... 阅读详情

Problem Description

Mr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bm is exactly the sequence aq,aq+p,aq+2p,⋯,aq+(m−1)p where q+(m−1)p≤n and q≥1.

Input

The first line contains only one integer T≤100, which indicates the number of test cases.Each test case contains three lines.
The first line contains three space-separated integers 1≤n≤106,1≤m≤106 and 1≤p≤106.
The second line contains n integers a1,a2,⋯,an(1≤ai≤109).
the third line contains m integers b1,b2,⋯,bm(1≤bi≤109).

Output

For each test case, output one line “Case #x: y”, where x is the case number (starting from 1) and y is the number of valid q’s.

Solution

KMP啊KMP……QAQ窝太弱了调了半个月

#include<stdio.h>
#include<cstring>
#define N 1000002

int a[N],b[N],P[N],n,m,p,ans;

inline int read()
{
    int x=0;char ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x;
}

inline void prepare()
{
    P[1]=0;int j=0;
    for (int i=2;i<=m;i++)
    {
        while (j && b[j+1]!=b[i]) j=P[j];
        if (b[j+1]==b[i]) j++;
        P[i]=j;
    }
}

inline void find(const int &st)
{
    int j=0;
    for (int i=st;i<=n;i+=p)
    {
        while (j && b[j+1]!=a[i]) j=P[j];
        if (b[j+1]==a[i]) j++;
        if (j==m) ans++,j=P[j];
    } 
}

int main()
{
    for (int t=1,T=read();t<=T;t++)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        memset(P,0,sizeof(P));
        n=read();m=read();p=read();
        for (int i=1;i<=n;i++) a[i]=read();
        for (int i=1;i<=m;i++) b[i]=read();prepare();
        for (int i=1;i<=p;i++) find(i);
        printf("Case #%d: %d\n",t,ans);ans=0;
    }
}
YOLO26 多任务统一架构:检测 / 分割 / 姿态 / OBB 设计 YOLO26提出了一种多任务统一架构,整合了目标检测、实例分割、姿态估计和旋转框检测(OBB)四大计算机视觉任务。该架构采用共享Backbone和Neck的设计,配合轻量级任务特定Head,解决了传统方法中多模型并行带来的高开发成本、大内存占用和低推理效率问题。核心设计包括:1)共享特征提取层实现参数复用;2)模块化Head结构支持灵活任务组合;3)统一接口实现单模型多任务处理。实验表明,该架构在保持各任务性能的同时显著提升了系统效率,为多任务视觉系统提供了新的实现范式。 阅读详情

相关推荐

道闸不自动落杆故障排查:从传感器原理到控制器调试全解析

在工业自动化和物联网系统中,传感器与控制器构成的闭环控制是保障设备可靠运行的核心。其基本原理是通过传感器采集环境状态,控制器依据预设逻辑做出决策并驱动执行器动作。这一技术价值在于实现了无人值守下的安全、高效自动化,广泛应用于智能交通、安防和智能楼宇等领域。以停车场道闸系统为例,其自动落杆功能高度依赖地感线圈与防砸雷达的协同。地感线圈作为触发单元,负责感知车辆接近;而防砸雷达则作为持续监测的安全单元,通过微波探测防砸区域内是否有障碍物,其信号是控制器执行落杆决策的关键依据。当系统出现车辆通过后闸杆不落的典型故

weixin_29190651的博客 318

【HDU - 5918 】Sequence I (数组(字符串)匹配问题,可选KMP)

题干: Mr. Frog has two sequences a1,a2,⋯,ana1,a2,⋯,an and b1,b2,⋯,bmb1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bmb1,b2,⋯,bm is exactly the sequence...

xuanweiace的博客 696

ColorOS13系统账户锁与密码锁破解全指南:从恢复模式到激活绕过

本文针对ColorOS13系统用户,详细解析了忘记锁屏密码(数字/图案锁)和遭遇OPPO账户锁(激活锁)的合法解决方案。核心是通过官方恢复模式进行格式化操作清除锁屏密码,并强调账户锁需通过密码找回或官方售后等正规途径解除。文章旨在帮助设备合法所有者恢复使用权,并提供了安全操作指南与数据备份建议。

weixin_28304023的博客 981

hdu5918Sequence I+KMP

Problem Description Mr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bm is exactly the sequence aq,aq+p,aq+2p,

xtulollipop 457

树莓派安装snowboy

1、树莓派换源 参考链接:https://blog.csdn.net/qq_43556844/article/details/113615915 2、更新pip3 参考链接:https://blog.csdn.net/qq_43556844/article/details/113616214 3、存取麦克风 我们使用PortAudio作为音频输入/输出的跨平台支持。我们还使用sox作为快速实用程序来检查麦克风设置是否正确。 sudo apt-get install python-pyaudio python

qq_43556844的博客 1927

论文理解【LLM-Clarification】—— 【QDrawer】Asking the Right Question at the Right Time: Human and Model Unce

本文基于 CoDraw 任务对 LLM 澄清提问的触发方式进行探索,发现模型内部不确定性与人类澄清决策相关性弱,使用不确定性阈值触发澄清提问相比模仿人类提问时机,性能和计算效率都更好

佚失的诗篇 783

2016中国大学生程序设计竞赛(ccpc 长春)题解报告

2016中国大学生程序设计竞赛(ccpc 长春)题解报告

queuelovestack的专栏 8671

SECS/GEM协议中的关键指令详解:从S1F1到S9F9的完整指南

本文详细解析了SECS/GEM协议中从S1F1到S9F9的关键指令,涵盖设备状态管理、控制诊断、报警处理等核心功能。通过实际案例和调试技巧,帮助开发者掌握半导体制造设备通信标准,解决SECS/GEM协议在实际工程应用中的通讯难题,提升生产线智能化水平。

weixin_26899659的博客 408

HDU 5918 Sequence I【KMP?】【2016中国大学生程序设计竞赛(长春)】

题意:给定序列aa、序列bb和一个整数pp,要求出有多少个qq使得b_1,b_2,\ldots,b_mb ​1 ​​ ,b ​2 ​​ ,…,b ​m ​​ 恰好是a_q,a_{q+p},\ldots,a_{q+(m-1)p}a ​q ​​ ,a ​q+p ​​ ,…,a ​q+(m−1)p ​​ 。 题解:将aa按照 \mathrm{mod}\ pmod p拆成若干个串,分别做一次 KMP. 其实可以不用KMP。

AC_Dreameng 874

AI Agent评估:指标、策略与最佳实践

AI智能体正逐渐融入到各个领域,从日常的对话助手到复杂的工作流程自动化,其应用范围不断拓展。然而,确保这些智能体能够可靠、高效地完成任务至关重要,这就使得AI智能体评估成为了人工智能发展过程中不可或缺的一环。本文将深入探讨AI智能体评估的指标、策略以及最佳实践,为读者全面解读这一关键领域。

llm_way的博客 3508

【全解析 | PTA】浙大版《Python 程序设计》题目集-第一章

Python浙大版PTA题解

wzhh_的博客 5533

Sequence注解

@Id @SequenceGenerator(name="sequenceGenerator",sequenceName="ACTIVITIESSCOPE_SEQ",allocationSize=1) @GeneratedValue(generator="sequenceGenerator",strategy=GenerationType.SEQUENCE) @Column(name = "

lvjianyu2007的专栏 3838

LVGL 组件对齐方式说明

本文说明 LVGL(以 v8 为例)中常用的 lv_align_t对齐选项的含义与用法,对应界面设计工具里下拉列表中的以及等命名。

摸鱼专家 139

HDOJ 5918 Sequence I 【2016CCPC长春现场赛】KMP暴力

KMP匹配是模板题:这个题改了之后的模板题 问:每次需要间隔P个字符,求匹配数 间隔P个字符,那么我们可以分成多个子串去求咯? 把大串分解成很多很多个小串,以P为间隔(也就是分成了P个) 然后查询P次 直接用BIN神模板,会出现一个很蠢的问题:next数组求了很多次! 所以,这个题把求next数组的部分拿到外面来 然后分成以P为间隔,分成多个新的数组就好!!!

ACdream 456

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

HDU - 5918 Sequence I

Mr. Frog has two sequences a1,a2,⋯,ana1,a2,⋯,an and b1,b2,⋯,bmb1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bmb1,b2,⋯,bm is exactly the sequence 

CS33sun的博客 552

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

[HDU5918]Sequence I

Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description Mr. Frog has two sequences a1,a2,⋯,ana_1,a_2,⋯,a_na1​,a2​,⋯,an​ and b1,b2,⋯,bmb_1,b_2,⋯,b_mb1​,b2​,...

dxyinme-Zz 314

hdu 5918 Sequence I (kmp)

胡改一波kmp模板

巴达鸟巴达鸟 754

Sequence I

Mr. Frog has two sequences a1,a2,⋯,ana1,a2,⋯,an and b1,b2,⋯,bmb1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bmb1,b2,⋯,bm is exactly the sequence aq,a

黑脉金的博客 783

atcoder092(中)ARC092 D - Two Sequences

【题意】给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1 #include #include #include #include //#include //#include //#include #include #include using namespace std; int n; #define maxn 200011 int a[maxn], b[maxn], na[

Every Master was once a disaster or beginner. 326

HDU Sequence I 2016中国大学生程序设计竞赛(长春)-重现赛

Sequence I Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0 Problem Description Mr. Frog has two sequences a1,a2,⋯

LuRiCheng的博客 1065

从键盘输入20个数a1到a20,计算并输出b1到b10,b1=根号(a1*a1+a20*a20),...,b10=根号(a10*a10+a11*a11)

小程序示例:int main() { int i,j, a[20]; double b[10]; for (i = 0; i < 20;i++) { scanf("%d",&a[i]); //从键盘输入20个数存入a[20] } for (j = 0; j < 10;j++) { b[j] = sqrt

liebecl的博客 511

XTU 1250 Super Fast Fourier Transform

Bobo has two sequences of integers {a1,a2,…,an} and {b1,b2,…,bm}. He would like to find ∑i=1n∑j=1m⌊|ai−bj|−−−−−−−√⌋. Note that ⌊x⌋ denotes the maximum integer does not exceed x, and |x| denotes the absolute value of x. Input The input contains at most 30

无知的渣渣的博客 788

hdoj-1005-Number Sequences

题目:Number Sequences 代码: #include #include #include #include using namespace std; int Ns[100]; int main() { int n,a,b,i; while(scanf("%d%d%d",&a,&b,&n)!=EOF) { if(a==0 && b==0 && n=

Wasdns 323

HDU - 5918 Sequence I

Mr. Frog has two sequences a1,a2,⋯,ana1,a2,⋯,an and b1,b2,⋯,bmb1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bmb1,b2,⋯,bm is exactly the sequence aq,a...

还我笑颜 386

HDU5918 Sequence I

Sequence I Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1234    Accepted Submission(s): 469 Problem Description Mr. Frog has two seq

要做ADC 558

HDU 5918 Sequence I (kmp)

思路:从a串第一个元素i开始作为起点,他的下一个节点位置为i+=p,由此到结尾进行一遍kmp。 然后在从a串的第二个元素开始作为起点,他的下一个节点位置为i+=p,由此到结尾进行一遍kmp。 直到以p位置为起点,进行一遍kmp。至此将a串遍历了一遍,结果也就出来了。AC代码: #include <iostream> #include <cstdio> #include <ctime> #incl

普通で歩む 565

HDU5918 Sequence I(kmp,间隔匹配)

Problem Description Mr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bm is exactly the sequence aq,aq+p

riba2534的博客 729
上一篇: 【HDOJ】5945 Fxx and game
下一篇: 【BZOJ】1003 [ZJOI2006]物流运输
Pure_W
博客等级 码龄10年 19粉丝 158原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值