/*  解码 _________________________________________________________________________________

                               #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. convertdate

    sample date 2015-09-10 00:00:00 2015-09-09 00:00:00.000 expect iso date, add time zone 2015-09-10T00 ...

  2. 触发Full GC执行的情况

    除直接调用System.gc外,触发Full GC执行的情况有如下四种. 1. 旧生代空间不足 旧生代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足的现象,当执行Full GC后空间仍然 ...

  3. java 调用 sql server存储过程

    Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...

  4. python sqlite 插入的数据含有变量,结果不一致

    def insert(): conn = sqlite3.connect("sqlite.db") print "open database passed" t ...

  5. OPENCV配置 C1083: 无法打开包括文件:“opencv2/opencv.hpp”

    本人没实操过C/C++,理论看过不少. 目前出于提升技术的考虑想做OPENCV 配置了2天,总算是配置好了..遇到不少问题. 计算机配置WIN10,用户环境变量配置也郁闷过... JDK等配置方式,配 ...

  6. LeetCode 102

    方法一:(迭代) /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...

  7. 缺少动态连接库.so--cannot open shared object file: No such file or directory

    总结下来主要有3种方法:1. 用ln将需要的so文件链接到/usr/lib或者/lib这两个默认的目录下边 ln -s /where/you/install/lib/*.so /usr/lib sud ...

  8. Robot_bfs

    Description The Robot Moving Institute is using a robot in their local store to transport different ...

  9. git使用学习

    windows系统需要安装git,mac系统自带git git相关命令: git clone  https://git.coding.net/tenchina/wangteng_python1.git ...

  10. 字符编码详解及由来(UNICODE,UTF-8,GBK)[转帖]

    相信許多人對字符編碼都不是很了解,透過下文可以清晰的理解各种字符编码方式详解及由来. 一直对字符的各种编码方式懵懵懂懂,什么ANSI.UNICODE.UTF-8.GB2312.GBK.DBCS.UCS ...