当前位置:网站首页>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);
}
}
边栏推荐
- Thesis learning record essay multi label lift
- Call us special providers of personal cloud services for College Students
- HDU - 1501 Zipper(记忆化深搜)
- 阶乘约数(唯一分解定理)
- Flink practice -- multi stream merge
- Pychart configuring jupyter
- 无限水平大理石游戏
- highmap gejson数据格式转换脚本
- Why use huluer pie disk instead of U disk?
- three. JS summary
猜你喜欢

ArcServer密码重置(账号不可以重置)

Smartinstantiationawarebeanpostprocessor of the extension point series determines which construction method to execute - Chapter 432

MongoDB:一、MongoDB是什么?MongoDB的优缺点

excel可视化

excel动态图表

解决麒麟V10上传文件乱码问题

让田头村变甜头村的特色农产品是仙景芋还是白菜

Don't put your notes and videos everywhere!

Scope data export mat

Excel dynamic chart
随机推荐
MySQL中 in 和 exists 的区别
Stack Title: parsing Boolean expressions
Arcserver password reset (account cannot be reset)
Linux closes the redis process SYSTEMd+
让厦门灌口镇田头村变甜头村的特色农产品之一是蚂蚁新村
健康照明中应用的LED照明灯
Make: g++: command not found
Database problems, how to optimize Oracle SQL query statements faster and more efficient
excel動態圖錶
论文学习记录随笔 多标签之GLOCAL
Pychart configuring jupyter
OpenGL es: (4) detailed explanation of EGL API (Continued)
MySQL怎么存储emoji?
Using Baidu map to query national subway lines
One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is
Advanced drawing skills of Excel lecture 100 (1) - use Gantt chart to show the progress of the project
Diffusion (multi-source search)
OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline
kubeadm搭建kubenetes 集群(个人学习版)
make: g++:命令未找到