/*  解码 _________________________________________________________________________________

                               #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. eap-tls

    eap-tls       文件路径 用途 示例 备注 #gedit /usr/local/etc/raddb/sites-available/default #gedit /usr/local/et ...

  2. web.config 配置

    一.认识Web.config文件   Web.config 文件是一个xml文本文件,它用来储存 asp.NET Web 应用程序的配置信息(如最常用的设置asp.NET Web 应用程序的身份验证方 ...

  3. C# 学习电子书资料分享mobi epub等格式

    .NET之美:.NET关键技术深入解析 作者: 张子阳 出版社:机械工业出版社 大小:20.29MB 出版时间:14-01-01 格式:mobi ASP.NET 4权威指南 作者: 马伟 出版社: 大 ...

  4. NSLOG打印不全的问题

    #ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr, "%s:%zd\t%s\n", [[[NSString string ...

  5. 将list转换为datatable的方法

    public static DataTable CopyToDataTable<T>(this IEnumerable<T> array) { var ret = new Da ...

  6. JQuery的一些简单操作01

    一.JQuery的隐藏和显示效果 1.hide/show/toggle hide隐藏效果,hide(1000)括号里面跟毫秒,show显示效果同样后面括号可以有数值,toggle开关按钮,交替作用隐藏 ...

  7. 在Visual Studio中使用Git命令提示符

    VS2015自带了Git插件,但有时候我觉得Git控制台命令更方便些. VS中本身不能把Git Bush作为浮动窗集成进来,但我们可以通过Power Shell来使用Git命令. ---------- ...

  8. Json序列化

    参考文章 C# 解析json的方法 http://www.cnblogs.com/txw1958/archive/2012/08/01/csharp-json.html

  9. amazon oa1 - search in 2D array II [Leetcode] 240

    https://leetcode.com/problems/search-a-2d-matrix-ii/ 巧解题,矩阵本身等于了一个binary search tree,从中值开始走 时间复杂度 O( ...

  10. golang http服务器跨域问题解决

    func main() { openHttpListen() } func openHttpListen() { http.HandleFunc("/", receiveClien ...