这道题目是队友写的,貌似是用暴力枚举出来. 题意:给出一组数,要求这组数在解锁的界面可能的滑动序列. 思路:按照是否能够直接到达建图,如1可以直接到2,但是1不能直接到3,因为中间必须经过一个2. 要注意的假如2已结访问过,那么1就可以直接到2. 建图DFS,图要更新. Source Code: #include <stdio.h> #include <string.h> ], ans[], n, vis[], k, fun[][]; ][] = { {}, {,,,,,,,,,}…
不知道为什么比赛的时候一直想着用DFS 来写 一直想剪枝结果还是TLE = = 这题数据量不大,又是问最优解,那么一般来说是用 BFS 来写 int commandi[4] = {1, 2, 3, 4}; 我定义了一个方向数组,其实题目意思中的,指针移动还有操作版的变化本质上都是指针的移动 在此只需要 额外定义一个变量 cur 在数组 commandi 中循环移动即可 这道题目还是因为数据量不大吧,直接用 STL 中的 Queue 即可,优先队列肯定会更快. 总体来说,还是一道容易题. Sour…
题目传送门 /* 题意:手机划屏解锁,一笔连通所有数字,输出所有可能的路径: DFS:全排列 + ok () 判断函数,去除一些不可能连通的点:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <map> #include <cmath> #include…
3861 - Valid Pattern Lock Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3861 Description Pattern lock security is generally used in Android handsets instead of a password. The pattern lock can b…
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861 思路 先生成全排列,然后判断哪些情况不符合的,剔除就好了 代码中 init() 部分 就是 先指明 哪两个数字之间 是必须有另外一个数字的 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #include &…
Description Pattern lock security is generally used in Android handsets instead of a password. The pattern lock can be set by joining points on a 3 × 3 matrix in a chosen order. The points of the matrix are registered in a numbered order starting wit…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861 这道题当时没做出来,后来经过队友提醒才做出来. 3*3的九宫格,给你其中n个点按下面要求连起来: 1. 给你的n个点都要激活(至少经过一次) 2. 如果点A,B相连后要经过另一个点C,则C在序列中的位置必须在A,B之前 如 1 7 4是不合法的 3.线段相交是没关系的,如 7 6 9 4 我是直接生成n个数的全排列,然后在所有排列里面去掉不合法的. #include…
Inversion Time Limit 1s Memory Limit 131072KB Judge Program Standard Ratio(Solve/Submit) 15.00%(3/20) Description: bobo has a sequence a1,a2,…,an. He is allowed to swap two adjacent numbers for no more than k times. Find the minimum number of inversi…
Description: 有一个大整数.不超过1000位.假设有N位.我想删掉其中的任意S个数字.使得删除S位后,剩下位组成的数是最小的. Input: 有多组数据数据,每组数据为两行.第一行是一个大整数.第二行是个整数S,其中S小于大整数的位数. 输入以EOF结束. Output: 对于每组输入数据,请输出其删除后的最小数. Sample Input: 178543 4 100002 1 Sample Output: 13 2 解题思路: 删除比它下一位大的数字,删除S次即可 注意的是要对答案…
无邪的飞行棋 Time Limit 1s Memory Limit 64KB Judge Program Standard Ratio(Solve/Submit) 15.38%(4/26) Description: 大家还记得小时候玩过的飞行棋游戏吧,和小伙伴们一起体验飞行的乐趣!随着岁月的流逝我们换个方法重温这个游戏. 开始我们都在起点0,我们的目标是到达目的地M(0 < M < 1000).现在我们手中有N(0 < N < 100)种点数,每种点数的大小为K(0 < k…