博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
uva1262
阅读量:4322 次
发布时间:2019-06-06

本文共 2031 字,大约阅读时间需要 6 分钟。

1                                2                           /*  解码 _________________________________________________________________________________ 3                              4                               #include 
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std; 13 #define fir first14 #define sec second15 #define pb(x) push_back(x) 16 #define mem(A, X) memset(A, X, sizeof A)17 #define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))18 #define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i)) 19 #define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e) 20 typedef long long LL; 21 typedef unsigned long long ull;22 typedef pair
pll; 23 24 25 LL T,n;26 int k;27 const int mod=1e9+7; 28 const int maxn=1e5+10; 29 char s[2][6][10],ans[10];30 int cnt;31 bool dfs(int col)32 {33 if(col==5)34 {35 if(++cnt==k) 36 { 37 ans[5]='\0';38 printf("%s\n",ans); 39 return true;40 }41 else 42 return false;43 }44 else45 {46 bool vis[2][26];47 mem(vis,false);48 49 REP(i,0,1)50 REP(j,0,5) 51 vis[i][ s[i][j][col]-'A' ]=true; //只处理当前列对应的可能位置,搜索时只处理当前层。52 53 REP(j,0,25) 54 if(vis[0][j]==true && vis[1][j]==true)55 {56 ans[col]=j+'A';57 if( dfs(col+1) ) return true;58 } 59 }60 return false;61 62 }63 64 int main()65 {66 freopen("in.txt","r",stdin); 67 //while(cin>>n)68 while(scanf("%d",&T)!=EOF)69 { 70 REP(kase,1,T) 71 {72 scanf("%d",&k);73 REP(i,0,1)74 REP(j,0,5) 75 {76 scanf("%s",&s[i][j]);77 //printf("%s\n",s[i][j]);78 }79 cnt=0;80 if(!dfs(0)) puts("NO"); 81 }82 83 }84 return 0;85 }86 87 /*88 note : 编码理论 89 本题运用的暴力方法,编写简单,90 如果用直接构造性的编码,实现时要注意更多的细节。91 92 93 debug : 94 optimize:95 直接操纵输入的字符,减少中间的传递,简化过程。96 二维的数组字母表,处理多个相似的对象时进行优化。97 */

 

转载于:https://www.cnblogs.com/paulzjt/p/6075410.html

你可能感兴趣的文章
十二种获取Spring的上下文环境ApplicationContext的方法
查看>>
UVA 11346 Probability 概率 (连续概率)
查看>>
linux uniq 命令
查看>>
Openssl rand命令
查看>>
HDU2825 Wireless Password 【AC自动机】【状压DP】
查看>>
BZOJ1015: [JSOI2008]星球大战starwar【并查集】【傻逼题】
查看>>
HUT-XXXX Strange display 容斥定理,线性规划
查看>>
mac修改用户名
查看>>
一道关于员工与部门查询的SQL笔试题
查看>>
Canvas基础
查看>>
[Hive - LanguageManual] Alter Table/Partition/Column
查看>>
可持久化数组
查看>>
去除IDEA报黄色/灰色的重复代码的下划波浪线
查看>>
Linux发送qq、网易邮件服务配置
查看>>
几道面试题
查看>>
【转】使用 WebGL 进行 3D 开发,第 1 部分: WebGL 简介
查看>>
js用正则表达式控制价格输入
查看>>
chromium浏览器开发系列第三篇:chromium源码目录结构
查看>>
java开发操作系统内核:由实模式进入保护模式之32位寻址
查看>>
第五讲:单例模式
查看>>