/*  解码 _________________________________________________________________________________

                               #include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define fir first
#define sec second
#define pb(x) push_back(x)
#define mem(A, X) memset(A, X, sizeof A)
#define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))
#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;
typedef unsigned long long ull;
typedef pair<long,long> pll; LL T,n;
int k;
const int mod=1e9+7;
const int maxn=1e5+10;
char s[2][6][10],ans[10];
int cnt;
bool dfs(int col)
{
if(col==5)
{
if(++cnt==k)
{
ans[5]='\0';
printf("%s\n",ans);
return true;
}
else
return false;
}
else
{
bool vis[2][26];
mem(vis,false); REP(i,0,1)
REP(j,0,5)
vis[i][ s[i][j][col]-'A' ]=true; //只处理当前列对应的可能位置,搜索时只处理当前层。 REP(j,0,25)
if(vis[0][j]==true && vis[1][j]==true)
{
ans[col]=j+'A';
if( dfs(col+1) ) return true;
}
}
return false; } int main()
{
freopen("in.txt","r",stdin);
//while(cin>>n)
while(scanf("%d",&T)!=EOF)
{
REP(kase,1,T)
{
scanf("%d",&k);
REP(i,0,1)
REP(j,0,5)
{
scanf("%s",&s[i][j]);
//printf("%s\n",s[i][j]);
}
cnt=0;
if(!dfs(0)) puts("NO");
} }
return 0;
} /*
note : 编码理论
本题运用的暴力方法,编写简单,
如果用直接构造性的编码,实现时要注意更多的细节。 debug :
optimize:
直接操纵输入的字符,减少中间的传递,简化过程。
二维的数组字母表,处理多个相似的对象时进行优化。
*/

uva1262的更多相关文章

  1. 10-8 uva1262密码

    题意:有两个图,每一列都存在的字母选作密码,就第k大的密码 思路: 找出各个位置上的密码, 假设: 第1个字母只能是{A,C,D,W}, 第2个字母只能是{B,O,P}, 第3个字母只能是{G,M,O ...

  2. UVA 1262 Password

    https://vjudge.net/problem/UVA-1262 字典序第k小 注意两点: 1. k-- 2.去重 #include<cstring> #include<cst ...

  3. UVA 1262 Password 暴力枚举

    Password Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID:  ...

随机推荐

  1. Wen前端性能优化

    Web前端性能优化 一般说来Web前端指网站业务逻辑之前的部分,包括浏览器加载.网站视图模型.图片服务.CDN服务等.主要优化手段有优化浏览器访问.使用反向代理.CDN等. 一.浏览器访问优化 减少h ...

  2. Dotspatial 创建面状图层

    using DotSpatial.Controls;using DotSpatial.Data;using DotSpatial.Data.Forms;using DotSpatial.Plugins ...

  3. Activity 生命周期

    Activity 的四种基本状态 1.运行态(Running) Activity 处于屏幕最前端,用户可见且获得焦点. 2.暂停态(Paused) Activity被置于后台,用户可见,但失去焦点 3 ...

  4. SimpleAdapter的使用

    SimpleAdapter的使用       SimpleAdapter是一个简单的适配器,该适配器也继承了BaseAdapter,对于布局是固定而言,使用简单适配器开发时非常简单了,由于Simple ...

  5. android原生ExpandableListView

    android原生可扩展ExpandableListView就是可以伸缩的listView,一条标题下面有多条内容. 这个list的adapter对的数据要求与普通ListView的数据要求也有一些差 ...

  6. jquery自定义插件——以 选项卡插件为例

    一直打算尝试自定义插件,终于付诸实践了,现在把内容发表出来,与大家共勉. 我是根据自己正在用的插件,模仿其源码,实现的自定义插件,完成之后,在网上看相关资料,对自定义插件部分,有了更明确的认识. jq ...

  7. ionic cordova 热更新(引用自www.zyyapp.com/post/116.html)

    上篇文章cordova 把html打包成安卓应用 http://www.zyyapp.com/post/115.html cordova 热更新是一个大坑,我看了一天一夜才明白.网上的教程都没说到重点 ...

  8. 二叉树的实现与一些基本操作(C++环境)

    #include<cstdio>#include<cstdlib>#include<iostream>#include<cstring>using na ...

  9. spring.net 如何让xml智能提示

    tools ->options ->Text Editor ->xml ->miscellaneous ->network ->勾选 automatically d ...

  10. Adobe Dreamweaver代码编辑

    Adobe Dreamweaver 同义词 DW(Adobe Dreamweaver的缩写)一般指Adobe Dreamweaver Adobe Dreamweaver,简称“DW”,中文名称 &qu ...