uva1262 Password【解法二】

原创 2016年08月31日 16:49:28

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 6  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. Figure 1. 6  5 window clips a valid grid representation for
a password. Assume that we have a length-5 password such as p 1 p 2 p
3 p 4 p 5 . In order to pass the authentication procedure, we should
construct a configuration of grid space where each p i appears in the
-th column of the grid. In that situation we say that the user password is accepted. Figure 2. A valid grid representation for
password ‘COMPU’. 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. In
this password system, the position of each password charac- ter in
each column is meaningless. If each of the 5 characters in p 1 p 2 p 3
p 4 p 5 appears in the corresponding column, that can be considered
the correct password. So there are many grid configu- rations 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 6  5 grid
since there are too many password can- didates. In this 6  5 grid
space, maximally 6 5
= 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
con- figurations 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. 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. Input 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  K  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. Output 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 case


using namespace std;
vector<char> v[7];
char s1[10][10],s2[10][10],ans[7];
int k,n[7],now;
bool init()
    int i,j,x,y,z;
    for (i=1;i<=5;i++) v[i].clear();
    for (i=1;i<=6;i++)
    for (i=1;i<=6;i++)
    for (i=1;i<=5;i++)
      for (j=1;j<=6;j++)
        for (x=1;x<=6;x++)
          if (s1[j][i]==s2[x][i])
    for (i=1;i<=5;i++)
        if (v[i].empty()) return 0;
        while (n[i]<v[i].size()-1&&v[i][n[i]+1]>v[i][n[i]]) n[i]++;
    return 1;
void dfs(int p)
    if (p==6)
    for (int i=0;i<n[p];i++)
        if (now==k) return;
void solve()
    int i,j,x,y,z,tot=1;
    for (i=1;i<=5;i++)
    if (k>tot)
    for (i=1;i<=5;i++)
int main()
    int T;
    while (T--)
        if (!init())

php中Password Hashing加密方法详解

  • u011250882
  • u011250882
  • 2015年10月24日 11:18
  • 2584


MySQL数据库认证密码有两种方式: 1:MySQL 4.1版本之前是MySQL323加密 2:MySQL 4.1和之后的版本都是MySQLSHA1加密 还原有函数:AES_ENCRYPT()加密函数...
  • typa01_kk
  • typa01_kk
  • 2015年10月15日 19:03
  • 6142


在 PHP中,经常会对用户身份进行认证。本文意在讨论对密码的处理,也就是对密码的加密处理。 MD5 相信很多PHP开发者在最先接触PHP的时候,处理密码的首选加密函数可能就是MD5了,我当...
  • ivan820819
  • ivan820819
  • 2016年12月06日 15:34
  • 1579

uva1262 Password【解法一】

  • sdfzyhx
  • sdfzyhx
  • 2016年08月31日 16:39
  • 272


  • zh9406
  • zh9406
  • 2014年08月14日 21:09
  • 563

Password Uva1262 KMP

题意:给出一个字符串,求出最大的前缀和后缀且它能在串的中部找到,若存在则输出,否则输出 Just a legend 思路:KMPnext数组的应用,一些细节要非常注意!...
  • u014422052
  • u014422052
  • 2014年11月02日 23:04
  • 1512

uva 102 357 484 702709 714 825 10128解法与代码

  • 2011年08月30日 23:35
  • 130KB
  • 下载


题目大意: 给出两个6行5列的字母矩阵,找出满足如下条件的密码:密码中的每个字母在两个矩阵的对应列出现。现在找出字典序第k小的满足条件的密码. 题目分析: 因为数据量很小,所以可以采用暴...
  • shutdown113
  • shutdown113
  • 2017年11月22日 21:13
  • 25

uva 1262 Password

uva 1262 Password
  • tengfei461807914
  • tengfei461807914
  • 2016年09月17日 20:14
  • 170

UVA 1262编码(第k字典序)

点击打开链接 我们先统计分别在每一列均在两个矩阵出现的字母,然后从小到大排好序。 对于第一个样例来说,我们得到ACDW、BOP、GMOX、AP、GSU 第一个字母无论以什么开头 ...
  • Jeremy1149
  • Jeremy1149
  • 2016年10月15日 14:57
  • 332
您举报文章:uva1262 Password【解法二】