题是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. ASP.NET 概述

    https://msdn.microsoft.com/zh-cn/library/4w3ex9c2(VS.100).aspx ASP.NET 概述 更新:2007 年 11 月 ASP.NET 是一个 ...

  2. multi-tap

    multi-tap又称 multi-press . 是在手机,或者电视遥控上的keypad定义,有如下2类标准: 1. ITU-T E.161 2.T9 使用举例如下: Consider a typi ...

  3. JVM高级内存优化面试

    Sun HotSpot VM,是JDK和Open JDK中自带的虚拟机,也是目前使用范围最广的Java虚拟机. JVM内存分布程序计数器:是一块较小的内存空间,可以看作是当前线程所执行的字节码的行号指 ...

  4. 【工具学习】——Maven的安装与配置

    [含义] 什么是构建? 构建,英文build.构建包括编译.运行.生成文档.打包.部署等等工作内容,如果我们每天手工去干这些事情,那会浪费很多的时间.因此,构建管理工具应运而生. maven,作为项目 ...

  5. new String(str.getBytes(“gbk”),“gbk”)的用法详解

    new String(str.getBytes(“gbk”),“gbk”)的用法详解 前提是str存放的是汉字 一.如果是new String(str.getBytes(“gbk”),“gbk”)时, ...

  6. [Elasticsearch] 多字段搜索 (二) - 最佳字段查询及其调优(转)

    最佳字段(Best Fields) 假设我们有一个让用户搜索博客文章的网站,就像这两份文档一样: PUT /my_index/my_type/1 { "title": " ...

  7. 高性能服务器开发之C++定时器

    高性能服务器开发之C++定时器 来源: https://www.cnblogs.com/junye/p/5836552.html 写这篇文章前搜了下网上类似的文章,有很多,所以笔者的这篇文章就不对定时 ...

  8. 【BZOJ 2241 打地鼠】

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1430  Solved: 908[Submit][Status][Discuss] Descripti ...

  9. UVA10480:Sabotage(最小割+输出)

    Sabotage 题目链接:https://vjudge.net/problem/UVA-10480 Description: The regime of a small but wealthy di ...

  10. Idea 怎么远程debug

    注意的问题:远程debug别人的服务器只能开一个debug,所以当你的同事比你先远程debug同一台服务器时,你应该报Error running 某某ip地址 .unable to open debu ...