/*  解码 _________________________________________________________________________________

                               #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. EF实体框架数据操作基类(转)

    //----------------------------------------------------------------// Copyright (C) 2013 河南禄恒软件科技有限公司 ...

  2. 开启GZIP(转)

    因为在做一个项目,项目里面服务器主要提供数据,但是数据多了文件就大了,比较浪费流量和时间,我们便用Gzip来处理.我在本机上是apache,服务器上是IIS6.0,用的是php,那么我就在这里分享一下 ...

  3. https适配

    http://www.jianshu.com/p/f312a84a944c http://www.2cto.com/kf/201611/570823.html http://www.cnblogs.c ...

  4. entity framework 新手入门篇(1.5)-lambda表达式与linq

    在建立好了EF模型之后,先不着急使用它,在使用它之前,你还需要了解两个相关的技术,lambda表达式与linq. 作为微软C#语言中重要的语法糖-lambda表达式与LINQ,本质都是一个方法,以la ...

  5. alpha值的问题

    但凡图像都会涉及到透明度问题.使用透明度之后就可以看到多层图像.Alpha值就是用于描述透明度的参量.Alpha值是一个百分数,alpha=1表示源文件发出的光全部被观察者观察到. 既然是透明度,那么 ...

  6. layer弹框

    官网http://layer.layui.com/ /!*如果是页面层*/layer.open({ type: 1, content: '传入任意的文本或html' //这里content是一个普通的 ...

  7. SQL注入的常用函数和语句

    1.系统函数 version()   Mysql版本user()   数据库用户名database()    数据库名@@datadir   数据库路径@@version_compile_os   操 ...

  8. JavaScript面试题

    一道常被人轻视的前端JS面试题 标签(空格分隔): JavaScript function Foo() { getName = function () { alert (1); }; return t ...

  9. POJ 3067 原来是树状数组--真的涨姿势

    题意:计划在东边的城市和西边的城市中建路,东边的点从1.....n,西边的点从1......m,求这些点连起来后有多少个交叉. PS:这个题目没有任何思路,没想到是树状数组.... 交叉出5个点 分析 ...

  10. SqlServer性能优化索引(五)

    导入表结构: select * into ProductCategory from AdventureWorksDW2014.dbo.DimProductCategory select * into ...