UVALive - 5844
2024-09-04 17:35:46
Sample Input
2
3
mississippi
nni55i55ippi
2
foobar
|=o08ar
Sample Output
1
0
/**
题意:给出一个normal串,一个leet串,看能否符合关系的映射
做法:dfs 将两个串进行匹配注意初始化
**/
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#define maxn 110
using namespace std;
char ch[maxn];
char ch1[maxn];
char alp[][];
char c[];
int dfs(int k,int a,int b,int len,int len1)
{
if(a == len && b == len1) return ;
if(a == len || b == len1) return ;
for(int i=; i<k; i++)
{
if(b+i<len1)
{
memset(c,'\0',sizeof(c));
for(int j=; j<=i; j++)
{
c[j] = ch1[b+j];
}
bool isok = false;
if(strcmp(alp[ch[a]-'a'],"") == ) ///当前字母还没有匹配
{
isok = true;
strcpy(alp[ch[a]-'a'],c);
}
if(isok || (strcmp(alp[ch[a]-'a'] ,c) == ))
{
if(dfs(k,a+,b+i+,len,len1)) return ;
}
if(isok)
{
strcpy(alp[ch[a]-'a'],""); ///回溯
}
}
}
return ;
}
int main()
{
// freopen("in1.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
int k;
scanf("%d",&k);
memset(alp,'\0',sizeof(alp));
scanf("%s %s",ch,ch1);
int len = strlen(ch);
int len1 = strlen(ch1);
int tt = ; tt = dfs(k,,,len,len1);
printf("%d\n",tt);
}
return ;
}
最新文章
- /etc/fstab 文件配置项简单介绍
- sqlmap的安装方法
- MATLAB不运行也不报错
- easyui Tooltip 气泡信息提示
- 1026: [SCOI2009]windy数 - BZOJ
- CI 笔记,使用 json的参考文档(废弃)
- AES对称加密算法
- 单目录下多文件 makefile编写
- asp.net连接ORACLE数据库
- log4net结构
- C#版的抓包软件
- Java关键字之static
- ArrayList的ConcurrentModificationException异常和多线程下的异常
- 在Java里>;、>;>;、>;>;>;的含义
- thinkphp 5内置验证规则-基本版
- php的Allowed memory size of 134217728 bytes exhausted问题解决办法
- ASP.Net MVC 在ajax接收controller返回值为Json数据
- wcf 中客户端调用之死 感悟 wcf与原来的webservice2.0 的客户端调用区别(wcf调用完不关闭的话那就把web服务搞死了)
- Excel工作记录表制作
- [Tjoi2016&;Heoi2016]排序[01序列]
热门文章
- HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)
- 使用gradle打包时将依赖也合并入jar包
- oracle带条件的Insert语句
- 关于org.springframework.web.filter.CharacterEncodingFilter的学习
- Python数据分析(三)pandas resample 重采样
- [洛谷P2602][ZJOI2010]数字计数
- BZOJ1305 [CQOI2009]dance跳舞 【网络流】
- POJ3623 Best Cow Line, Gold 【后缀数组】
- 洛谷 [CQOI2015]选数 解题报告
- 插头dp题表