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

UVALive - 5844的更多相关文章

  1. UVALive 5844 dfs暴力搜索

    题目链接:UVAive 5844 Leet DES:大意是给出两个字符串.第一个字符串里的字符可以由1-k个字符代替.问这两个字符串是不是相等.因为1<=k<=3.而且第一个字符串长度小于 ...

  2. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  3. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  4. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  5. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  6. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  7. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  8. UVALive 6500 Boxes

    Boxes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  9. UVALive 6948 Jokewithpermutation dfs

    题目链接:UVALive 6948  Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...

随机推荐

  1. git - work flow

    git status – Make sure your current area is clean. git pull – Get the latest version from the remote ...

  2. HDU 4588 Count The Carries(数学统计)

    Description One day, Implus gets interested in binary addition and binary carry. He will transfer al ...

  3. C语言单元测试

    转自http://blog.csdn.net/colin719/article/details/1420583 对于敏捷开发来说,单元测试必不可少,对于Java开发来说,JUnit非常好,对于C++开 ...

  4. B树(B-树)

    1.基本概念: M定义为树的高度,也叫阶,就是树的深度: (1).B树又称为多路平衡查找树. (2).根节点至少有两个子节点. (3).除根节点以外的非叶子节点的儿子树为[M/2,M]. (4).每个 ...

  5. JVM(2)——GC算法和收集器

    一.引入 上篇博客<JVM--简介>中主要介绍了JVM的内存模型,思考一下: 为什么要划分堆.栈.方法区等? 为什么把不同种类的数据信息分别存放? 答案可以分为很多很多条,这里就说一个方面 ...

  6. enter & keypress

    enter & keypress https://stackoverflow.com/questions/905222/enter-key-press-event-in-javascript ...

  7. 瀑布模型&螺旋模型

    软件开发模型:1.瀑布模型1)软件概念阶段 用户需求2)需求分析 软件需求3)架构设计 架构文档4)详细设计 模型设计5)编码阶段 代码文档6)测试阶段瀑布模型的特点是在每个阶段的工作都清晰详尽,容易 ...

  8. something about Parameter Estimation (参数估计)

    点估计 Point Estimation 最大似然估计(Maximum Likelihood Estimate —— MLE):视θ为固定的参数,假设存在一个最佳的参数(或参数的真实值是存在的),目的 ...

  9. CLion 终于支持 jump outside closing bracket/quote with Tab 了!

    我觉得这个 feature 真的很有用.一直期待 CLion 加上这个 feature.今天才知道最新版本(CLion 2018.3.4)中已经有这个功能了,不过我不清楚从哪个版本开始支持的. How ...

  10. How do I see what character set a database / table / column is in MySQL?

    Q: How do I see what the character set that a MySQL database, table and column are in? Is there some ...