题目链接:https://cn.vjudge.net/contest/245287#problem/I 代码: 使用普通的队列和优先队列相比,优先队列能更快地找到目的变量. #include<iostream> #include<string> #include<cstring> #include<iomanip> #include<stack> #include<queue> #include<map> #include…
此题用深搜很快就解决,我用宽度搜索和优先队列仅仅是为了练习他们的用法:深搜法在注释内: 1 #include<iostream> #include<cstring> #include<queue> using namespace std; ; int map[N][N]; int vis[N][N]; int n; struct Node { int x,y,value; friend bool operator<(Node a,Node b) {return a…
There is an interesting calculator. It has 3 rows of buttons. Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of the display. Row 2: button +0, +1, +2, +3, ..., +9. Pressing each button adds that digit to the disp…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1336 There is an interesting calculator. It has 3 rows of buttons. Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of the display. Row 2: button +0, +1, +2, +3, ...…
1336: Interesting Calculator 这道题被LZQ抢了一血,于是去读题发现题意不难,纯广搜结果写的一塌糊涂. 题意:给你两个数x,y.由x每次可以经过一系列操作变换,每个变换都有一定的费用,求x变换到y的最小费用下最小步数. 思路:类似最短路的思想,当时只想到每个点有30个方向可以走,于是直接广搜,但不是TLE就是MLE,后来比完赛看题解才知道要用优先队列.最小费用优先,然后最小步数优先.每一步都是前一步到达的,但一个点可以由多个点到达,这时我们肯定要取最优的那一步嘛.如果…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1254 推箱子 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9942    Accepted Submission(s): 2920 Problem Description 推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的…
Interesting Calculator Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 163  Solved: 49 Description There is an interesting calculator. It has 3 rows of buttons.   Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of…
先上题目: 12664 Interesting CalculatorThere is an interesting calculator. It has 3 rows of button.• Row 1: button 0, 1, 2, 3, . . . , 9. Pressing each button appends that digit to the end of the display.• Row 2: button +0, +1, +2, +3, . . . , +9. Pressin…
目录 求树的最大独立集,最小点覆盖,最小支配集 三个定义 贪心解法 树形DP解法 (有任何问题欢迎留言或私聊&&欢迎交流讨论哦 求树的最大独立集,最小点覆盖,最小支配集 三个定义 最大独立集:  对一个图选出尽量多的点组成一个集合,满足这些点之间没有边相连.所有独立集中,顶点数最多的称作最大独立集. 最小点覆盖:  对一个图选出尽量少的点组成一个集合,满足图中所有的边均有端点属于这个集合.所有覆盖集中,顶点数最少的称作最小点覆盖. 最小支配集:  对一个图选出尽量少的点组成一个集合,满足图…
Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25203    Accepted Submission(s): 8936 Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is…