题是pdf版

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 ;
}

最新文章

  1. /etc/fstab 文件配置项简单介绍
  2. sqlmap的安装方法
  3. MATLAB不运行也不报错
  4. easyui Tooltip 气泡信息提示
  5. 1026: [SCOI2009]windy数 - BZOJ
  6. CI 笔记,使用 json的参考文档(废弃)
  7. AES对称加密算法
  8. 单目录下多文件 makefile编写
  9. asp.net连接ORACLE数据库
  10. log4net结构
  11. C#版的抓包软件
  12. Java关键字之static
  13. ArrayList的ConcurrentModificationException异常和多线程下的异常
  14. 在Java里&gt;、&gt;&gt;、&gt;&gt;&gt;的含义
  15. thinkphp 5内置验证规则-基本版
  16. php的Allowed memory size of 134217728 bytes exhausted问题解决办法
  17. ASP.Net MVC 在ajax接收controller返回值为Json数据
  18. wcf 中客户端调用之死 感悟 wcf与原来的webservice2.0 的客户端调用区别(wcf调用完不关闭的话那就把web服务搞死了)
  19. Excel工作记录表制作
  20. [Tjoi2016&amp;Heoi2016]排序[01序列]

热门文章

  1. HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)
  2. 使用gradle打包时将依赖也合并入jar包
  3. oracle带条件的Insert语句
  4. 关于org.springframework.web.filter.CharacterEncodingFilter的学习
  5. Python数据分析(三)pandas resample 重采样
  6. [洛谷P2602][ZJOI2010]数字计数
  7. BZOJ1305 [CQOI2009]dance跳舞 【网络流】
  8. POJ3623 Best Cow Line, Gold 【后缀数组】
  9. 洛谷 [CQOI2015]选数 解题报告
  10. 插头dp题表