King's Phone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 916    Accepted Submission(s): 261

Problem Description
In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen.

The pattern interface is a $3 \times 3$ square lattice, the three points in the first line are labeled as $1, 2, 3$, the three points in the second line are labeled as $4, 5, 6$, and the three points in the last line are labeled as $7, 8, 9$。The password itself is a sequence, representing the points in chronological sequence, but you should follow the following rules:

- The password contains at least four points.

- Once a point has been passed through. It can't be passed through again.

- The middle point on the path can't be skipped, unless it has been passed through($3427$ is valid, but $3724$ is invalid).

His password has a length for a positive integer $k (1\le k\le 9)$, the password sequence is $s_1,s_2...s_k(0\le s_{i} < INT\_MAX)$ , he wants to know whether the password is valid. Then the King throws the problem to you.

 
Input
The first line contains a number&nbsp;$T(0 < T \le 100000)$, the number of the testcases.

For each test case, there are only one line. the first first number&nbsp;$k$,represent the length of the password, then $k$ numbers, separated by a space, representing the password sequence $s_1,s_2...s_k$.

 
Output
Output exactly $T$ lines. For each test case, print `valid` if the password is valid, otherwise print `invalid`
 
Sample Input
3
4 1 3 6 2
4 6 2 1 3
4 8 1 6 7
 
Sample Output
invalid
valid
valid

hint:
For test case #1:The path $1\rightarrow 3$ skipped the middle point $2$, so it's invalid.

For test case #2:The path $1\rightarrow 3$ doesn't skipped the middle point $2$, because the point 2 has been through, so it's valid.

For test case #2:The path $8\rightarrow 1 \rightarrow 6 \rightarrow 7$ doesn't have any the middle point $2$, so it's valid.

 
Source
挂终测了  继续掉分 一回解  orzzzz 最近 太忙
题意: 给你一段序列 问是否为合法的解锁序列(模拟手机手势解锁)
 
满足条件 1.至少4个数字 数量为[4,9]  2.不能重复 3.不能跳跃 4.数字的范围为[1,9]
还有记得每次的初始化
 
 #include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int t;
int a[];
int mp[][];
map<int,int> mpp;
int jishu=;
void init()
{
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
mp[][]=;
}
int main()
{
scanf("%d",&t); init();
for(int i=;i<=t;i++)
{
scanf("%d",&jishu);
memset(a,,sizeof(a));
int maxn=;
int flag=;
for(int j=;j<=jishu;j++)
{
scanf("%d",&a[j]);
if(a[j]>maxn)
maxn=a[j];
if(a[j]<=)
flag=;
}
mpp.clear();
if(jishu<||jishu>||maxn>||flag==)
printf("invalid\n");
else
{ int re=;
mpp[a[]]=;
for(int j=;j<jishu;j++)
{
if(mpp[a[j+]]==)
{
if(mp[a[j]][a[j+]]==)
re++;
else
{
if(mpp[(a[j]+a[j+])/])
re++;
}
}
mpp[a[j+]]=; }
if(re==jishu-)
printf("valid\n");
else
printf("invalid\n");
}
}
return ;
}

HDU 5641的更多相关文章

  1. hdu 5641 BestCoder Round #75

    King's Phone  Accepts: 310  Submissions: 2980  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: ...

  2. hdu 5641 King's Phone

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5641 题目类型:水题 题目思路:将点x到点y所需要跨过的点存入mark[x][y]中(无需跨过其它点存 ...

  3. HDU 5641 King's Phone 模拟

    King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...

  4. hdu 5641 King's Phone(暴力模拟题)

    Problem Description In a military parade, the King sees lots of new things, including an Andriod Pho ...

  5. HDU 5641 King's Phone【模拟】

    题意: 给定一串密码, 判断是否合法. 长度不小于4 不能重复经过任何点 不能跳过中间点,除非中间点已经经过一次. 分析: 3*3直接记录出可能出现在两点之间的点,直接模拟就好. 注意审题,别漏了判断 ...

  6. Hdu 5036-Explosion 传递闭包,bitset,期望/概率

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5036 Explosion Time Limit: 6000/3000 MS (Java/Others)   ...

  7. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  9. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

随机推荐

  1. Bootstrap框架(图标)

    Glyphicons 字体图标 所有可用的图标 包括250多个来自 Glyphicon Halflings 的字体图标.Glyphicons Halflings 一般是收费的,但是他们的作者允许 Bo ...

  2. SpringCloud IDEA 教学 (二) Eureka Service

    写在开头 本篇继续介绍基于Eureka的SpringCloud微服务搭建,回顾一下搭建过程, 第一步:建立一个服务注册中心: 第二步:建立微服务并注入到注册中心: 第三步:建立client端来访问微服 ...

  3. php分页类的实现与调用 (自我摘记)

    page.class.php <?php namespace Component; class Page { private $total; //数据表中总记录数 private $listRo ...

  4. Martian Addition

    In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are ...

  5. Java学习个人备忘录之多态

    对象的多态性 class 动物 {} class 猫 extends 动物 {} class 狗 extends 动物 {} 猫 x = new 猫();//意思是建立本类的对象 new 猫(),并通 ...

  6. android仿美团客户端购买框悬浮特效

        实现步骤如下: 1,新建一个项目,新建一个MyScrollView继承自ScrollView   public class MyScrollView extends ScrollView { ...

  7. Ubuntu下FileZilla的安装

    FileZilla是一个免费而且开源的FTP客户端软件,共有两种版本:客户端版本.服务器版本.FileZilla有条理的界面和管理多站点的简化方式使得FileZilla Client成为一个方便高效的 ...

  8. 关于char, wchar_t, TCHAR, _T(),L,宏 _T、TEXT,_TEXT、L

    char :单字节变量类型,最多表示256个字符, wchar_t :宽字节变量类型,用于表示Unicode字符, 它实际定义在<string.h>里:typedef unsigned s ...

  9. 判断两个字符串是否相等【JAVA】

    if(A.equals(B)){ } 之前总是用"=="来判断,但是在JAVA里面好像不行.所以,用equals(). 查了下资料. 原因:equal()比较的是对象的内容,&qu ...

  10. 在 Range 对象中,Min (14)必须小于或等于 max (-1)。

    DataTable dt = ds.Tables[]; DataRow[] drs = dt.Select("Id=" + categoryID ); 解决方法:将参数用单引号阔起 ...