题是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. java-2018-01-17计划

    1.一句英语 包括单词 2.一个java版本的设计模式 参考:https://github.com/iluwatar/java-design-patterns 学习了抽象工厂模式 总结:java的RS ...

  2. vue2.0中父子组件之间的通信总结

    父组件: 子组件: 接受父组件的信息: 向父组件发送事件: (其中slot是插槽,可以将父组件中的<p>123</p>插入进来,如果父组件没有插入的内容,则显示slot内部的内 ...

  3. KVO 开发详情

    目录 概念 应用KVO的3个步骤 关联属性的KVO 手动管理KVO通知 一.概念 KVO全称是 Key-Value Observing ,是OC的一种消息发送机制.这个机制是指:假设将B对象注册为A对 ...

  4. Beats数据采集

    Beats数据采集 Beats是elastic公司的一款轻量级数据采集产品,它包含了几个子产品: packetbeat(用于监控网络流量). filebeat(用于监听日志数据,可以替代logstas ...

  5. 【bzoj2287】[POJ Challenge]消失之物 背包dp

    题目描述 ftiasch 有 N 个物品, 体积分别是 W1, W2, ..., WN. 由于她的疏忽, 第 i 个物品丢失了. “要使用剩下的 N - 1 物品装满容积为 x 的背包,有几种方法呢? ...

  6. 【题解】APIO2007动物园

    首先一眼感受到这题特别的性质……5个?这么小的,感觉就像是状压.脑补了一下,如果没有环的话应该很好做吧……有环怎么办?5真的很小的,随便乱搞肯定也可以.那就放在外面暴力枚举吧.然后正解就出来了. 然而 ...

  7. [洛谷P3865]【模板】ST表

    题目大意:区间静态最大值 题解:ST表,zkw线段树 ST表: st[i][j]存[i,i+$j^{2}$-1]的最大值,查询时把区间分成两个长度相同的小区间(可重复) #include<cst ...

  8. [51nod1503]猪和回文 DP

    ---题面--- 题解: 首先观察到题目要求的是合法回文串的个数,而回文串要求从前往后和从后往前是一样的,因此我们假设有两只猪,分别从左上和右下开始走,走相同的步数最后相遇,那么它们走的路能拼在一起构 ...

  9. jsp电子商务 购物车实现之二 登录和分页篇

    登录页面核心代码 <div id="login"> <h2>用户登陆</h2> <form method="post" ...

  10. JS Cookie相关操作

    function setCookie(cookieName, cookieValue, expires) { // 设置Cookie function getCookieName(cookieName ...