当前位置:网站首页>HDU - 1501 zipper (memory deep search)
HDU - 1501 zipper (memory deep search)
2022-07-01 06:12:00 【Great intelligence】
Portal
The question : give 3 A string a,b,c, ask c Yes No a,b Results after interleaving , That is to say a,b Without changing the character order of ,a,b The length of the string is less than 200
analysis : If you search directly and deeply , Complexity is 2^200, So we need to use memorization , Space also relieves time , Mark the past situation . Record in the search a,b,c length ,c The length of is equal to ab Sum of length , therefore book[a][b] Represents the same situation , Mark the next time you get to this point return;
AC Code :
#include<bits/stdc++.h>
using namespace std;
int inf=0x3f3f3f3f;
int l1,l2,l3;
char a[210],b[210],c[420];
int book[210][210];
int flag;
void dfs(int t1,int t2,int t3)
{
if(t3==l3)
{
flag=1;
return;
}
if(book[t1][t2])
return;
book[t1][t2]=1;
if(a[t1]==c[t3])
dfs(t1+1,t2,t3+1);
if(b[t2]==c[t3])
dfs(t1,t2+1,t3+1);
}
int main()
{
int t;
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
memset(book,0,sizeof(book));
flag=0;
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
l1=strlen(a);
l2=strlen(b);
l3=strlen(c);
dfs(0,0,0);
if(flag==1)
printf("Data set %d: yes\n",i);
else printf("Data set %d: no\n",i);
}
}
边栏推荐
- MySQL怎么存储emoji?
- srpingboot security demo
- 让厦门灌口镇田头村变“甜头”村的特色农产品之一是
- El tooltip in the table realizes line breaking display
- One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is
- FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述
- Retention rate of SQL required questions
- Multi label lsml for essay learning records
- 68 cesium code datasource loading czml
- Small guide for rapid completion of mechanical arm (VI): stepping motor driver
猜你喜欢

69 Cesium代码datasource加载geojson

Distributed lock implementation

OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)

FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述

jdbc 数据库操作

指数法和Random Forest实现山东省丰水期地表水体信息

Dear pie users, I want to confess to you!

Multi label lsml for essay learning records

PLA不粘贴在床上:6个简单的解决方案

基于LabVIEW的计时器
随机推荐
HDU - 1501 Zipper(记忆化深搜)
LED lighting used in health lighting
Projects and dependencies in ABP learning solutions
Oracle sequence + trigger
SystemVerilog学习-09-进程间同步、通信和虚方法
Talking from mlperf: how to lead the next wave of AI accelerator
Kubedm builds kubenetes cluster (Personal Learning version)
golang panic recover自定义异常处理
kubeadm搭建kubenetes 集群(个人学习版)
One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is
Transformer le village de tiantou en un village de betteraves sucrières
扩散(多源广搜)
浏览器端保存数据到本地文件
OpenGL es: (1) origin of OpenGL es (transfer)
讓田頭村變甜頭村的特色農產品是仙景芋還是白菜
扩展点系列之SmartInstantiationAwareBeanPostProcessor确定执行哪一个构造方法 - 第432篇
Flink实战--多流合并
OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)
CJC8988带2个立体声耳机驱动器的低功率立体声编解码器
SystemVerilog学习-10-验证量化和覆盖率