博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 1262 Password 暴力枚举
阅读量:5236 次
发布时间:2019-06-14

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

Password

Time Limit: 3000ms
Memory Limit: 131072KB
This problem will be judged on 
UVA. Original ID: 
64-bit integer IO format: 
%lld      Java class name: 
Main
 
     
 

Shoulder-surfing is the behavior of intentionally and stealthily watching the screen of another person's electronic device, such as laptop computer or mobile phone. Since mobile devices prevail, it is getting serious to steal personal information by shoulder-surfing.

Suppose that we have a smart phone. If we touch the screen keyboard directly to enter the password, this is very vulnerable since a shoulder-surfer easily knows what we have typed. So it is desirable to conceal the input information to discourage shoulder-surfers around us. Let me explain one way to do this.

You are given a x 5 grid. Each column can be considered the visible part of a wheel. So you can easily rotate each column wheel independently to make password characters visible. In this problem, we assume that each wheel contains the 26 upper letters of English alphabet. See the following Figure 1.

\epsfbox{p4845a.eps}

Figure 1. 
x 5 window clips a valid grid representation for a password.

Assume that we have a length-5 password such as p1 p2 p3 p4 p5. In order to pass the authentication procedure, we should construct a configuration of grid space where each piappears in the i-th column of the grid. In that situation we say that the user password is accepted.

Let me start with one example. Suppose that our password was set `COMPU'. If we construct the grid as shown in Figure 2 on next page, then the authentication is successfully processed.

\epsfbox{p4845b.eps}

Figure 2. A valid grid representation for password `COMPU'.

In this password system, the position of each password character in each column is meaningless. If each of the 5 characters in p1 p2 p3 p4 p5 appears in the corresponding column, that can be considered the correct password. So there are many grid configurations allowing one password. Note that the sequence of letters on each wheel is randomly determined for each trial and for each column. In practice, the user is able to rotate each column and press ``Enter" key, so a should-surfer cannot perceive the password by observing the x 5grid since there are too many password candidates. In this x 5 grid space, maximally 65 = 7, 776 cases are possible. This is the basic idea of the proposed password system against shoulder-surfers.

Unfortunately there is a problem. If a shoulder-surfer can observe more than two grid plate configurations for a person, then the shoulder-surfer can reduce the searching space and guess the correct password. Even though it is not easy to stealthily observe other's more than once, this is one weakness of implicit grid passwords.

Let me show one example with two observed configurations for a grid password. The user password is `COMPU', but `DPMAG' is also one candidate password derived from the following configuration.

\epsfbox{p4845c.eps}

Figure 3. Both of `COMPU' and `DPMAG' are feasible password .

You are given two configurations of grid password from a shoulder-surfer. Suppose that you have succeeded to stealthily record snapshots of the target person's device (e.g. smart phone). Then your next task is to reconstruct all possible passwords from these two snapshots. Since there are lots of password candidates, you are asked for the k-th password among all candidates in lexicographical order. In Figure 3, let us show the first 5 valid password. The first 5 valid passwords are `ABGAG' , `ABGAS', `ABGAU', `ABGPG' and `ABGPS'.

The number k is given in each test case differently. If there does not exist a k-th password since k is larger than the number of all possible passwords, then you should print `NO' in the output.

 

Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. The first line of each test case contains one integer, K, the order of the password you should find. Note that 1$ \le$K$ \le$7, 777. Next the following 6 lines show the 6 rows of the first grid and another 6 lines represent the 6 rows of the second grid.

 

Your program is to write to standard output. Print exactly the 
k-th password (including `
NO') in one line for each test case.

The following shows sample input and output for three test cases.

 

31AYGSUDOMRACPFASXBODGWDYPKPRXWOCBOPTDOSBGGTRARAPMMSWSXNUEFGHI5AYGSUDOMRACPFASXBODGWDYPKPRXWOCBOPTDOSBGGTRARAPMMSWSXNUEFGHI64FGHIJEFGHIDEFGHCDEFGBCDEFABCDEWBXDYUWYXZXXZFGYYFYHEZWZIZGHIJ

 

ABGAGABGPSNO

 
     
 

Distributed under GPLv3. |  | Developer:  | Current Style: Cerulean.

/* ***********************************************Author        :CKbossCreated Time  :2014年12月15日 星期一 10时08分57秒File Name     :UVA1262.cpp ************************************************ */#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;int k;char m1[10][10],m2[10][10];vector
vc[10];vector
vs;char str[10];void dfs(int deep){ if(deep==5) { string ans; for(int i=0;i<5;i++) ans+=str[i]; vs.push_back(ans); return ; } for(int i=0,sz=vc[deep].size();i
tt) puts("NO"); else { cout<
<

转载于:https://www.cnblogs.com/jhcelue/p/7278644.html

你可能感兴趣的文章
Spring的JdbcTemplate、NamedParameterJdbcTemplate、SimpleJdbcTemplate
查看>>
Mac下使用crontab来实现定时任务
查看>>
303. Range Sum Query - Immutable
查看>>
图片加载失败显示默认图片占位符
查看>>
【★】浅谈计算机与随机数
查看>>
解决 sublime text3 运行python文件无法input的问题
查看>>
javascript面相对象编程,封装与继承
查看>>
Atlas命名空间Sys.Data下控件介绍——DataColumn,DataRow和DataTable
查看>>
Java中正则表达式的使用
查看>>
算法之搜索篇
查看>>
新的开始
查看>>
java Facade模式
查看>>
NYOJ 120校园网络(有向图的强连通分量)(Kosaraju算法)
查看>>
SpringAop与AspectJ
查看>>
Leetcode 226: Invert Binary Tree
查看>>
http站点转https站点教程
查看>>
解决miner.start() 返回null
查看>>
bzoj 2007: [Noi2010]海拔【最小割+dijskstra】
查看>>
BZOJ 1001--[BeiJing2006]狼抓兔子(最短路&对偶图)
查看>>
C# Dynamic通用反序列化Json类型并遍历属性比较
查看>>