HDU 1240 Asteroids! 解题报告】的更多相关文章

//这道题做完我只有 三个感受  第一:坑: 第二 : 坑! 第三:还是坑! 咳咳  言归正传  WA了无数次之后才发现是输入进去时坐标时z, y, x的顺序输入的 题解   :  类似胜利大逃亡 只不过给你了起始坐标和终点坐标, 让你输出到达目标点所需最少步数: 输出时第一个输出时是START读入的map大小值n;第二个是所求步数 //细节: 1.读入:   读入时分别两次%S把没用的START 和 END读取掉: 2.输出时输出 三维坐标大小值n, 以及步数: 3.输入进去时开始点和结束点坐…
Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3159    Accepted Submission(s): 2106 Problem Description You're in space.You want to get home.There are asteroids.You don't want to hit…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b2, ...,  bt.需要满足两个条件(1)b1≤b2≤…≤bt   (2)b2−b1≤b3−b2≤⋯≤bt−bt−1.求出最大的 t 为多少. 遗留大半年的题目呀呀呀呀~~~~!!!首先非常感谢乌冬子大半年前的指点迷津,呕心沥血想了大半天举出个反例,以便指出我算法的错误.为了纪念这个伟大的人物(…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896 题目意思:给出 n 块石头的初始位置和能到达的距离.对于第奇数次遇到的石头才抛掷,偶数次的就忽略.问最多能扔到多远.如果有多颗石头在一个位置,距离小的那个标记为先遇到的. 所以先解说一下第二个测试案例: 2 1  5 6  6 在6这个位置的时候,由于5比6小,所以规定1(5)这个点是先遇上的,是偶数次遇到,所以忽略. 用优先队列做,位置近的优先级越高,如果位置相同,距离短的优先级越高. #i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1]<A[i]<A[i+1](1<i<K).现在要求的是,有多少人满足,(他坐的缆车的值 + 他左边缆车的值) % INT_MAX == 他右边缆车的值. 首先好感谢出题者的样例三,否则真的会坑下不少人.即同一部缆车可以坐多个人.由于缆车的值是唯一的,所以可以通过排序先排出缆车的位置.求出…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5162 题目意思:有 n 个 kid,每个 kid 有三个成绩 a, b, c.选最大的一个成绩作为这个 kid 的最终成绩.然后根据每个 kid 的最终成绩,对他们进行排名. 赛中写得比较丑陋,这个还比较顺眼....呵呵 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5163 题目意思:有 n 个车站,给出相邻两个车站的距离,即车站 i 和车站 i+1 的距离为 di (1≤ i <n).然后是 m 个人从他的出发点到他想去的终点(都是车站),约定轮到处理第 i 个人的时候,车站的出发点满足:((i-1) mod n) + 1 ,假设车每走一个单位的距离花费一个单位的时间,车开始的时候是从左到右开的.如果车走到最右的车站即车站 n 会调头,此时方向为从右到左开:如果…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5154 题目意思:有 n 门 processes(编号依次为1,2,...,n),然后给出 m 种关系: a,b.表示 process b 要在 process a 之前完成.问经过 m 种关系之后,有没有可能完成所有的 process. 可以利用拓扑排序的思想做.遍历所有 process,处理所有入度为 0 的点,然后把与该点关联的点,即度数都减一.这样处理完之后,每个点的度数应该都是-1,否则就代…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5067 题目意思:给出一个 n * m 的方格,每一个小方格(大小为1*1)的值要么为 0 要么为一个正整数.规定是正整数的值得方格个数不超过 10 个.现在问从最左上角的点开始,要经过所有正整数的值的点之后,要返回到最左上角的点的最短路径是多少. 其实为正整数的那些点具体值是什么根本无关紧要.可以先求出所有点到其他点的两两最短路径,然后利用状态压缩 (考虑到只有10个点,状态数最多为2^10)来求出…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1425 常规的方法是对输入的数从大到小进行排序(可以用sort或qsort),然后输出前m大的数. 不过此题实质上是hash的入门题.建立一个比较大的数组,然后把这些数通过hash函数计算映射到这个数组里面(这里hash函数是 tmp + 500000,tmp是输入的n个数中任意的一个数),考虑到这些数是各不相同的,因此不需要考虑冲突问题. #include <iostream> #include…
Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2599    Accepted Submission(s): 1745 Problem Description You're in space. You want to get home. There are asteroids. You don't want to…
题目链接 Problem Description You're in space.You want to get home.There are asteroids.You don't want to hit them.   Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1361 题目意思: 根据输入的P-sequence , 输出对应的W-sequence.   P-sequence: 表示每个右括号前有多少个左括号;   W-sequence: 表示每个右括号要经过多少个左括号才能找到它能够匹配的左括号. 可以通过栈来做,边输入边处理.假设左括号用-1表示, 已经匹配好的括号(即 () ) 用1表示.那么,如果是左括号的话,就把-1压进去.直到找到匹配的括号. 以…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 题目意思:就是求大整数加法.有多个案例,每个案例之间要输出一个空格. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; + ; char t[maxn]; int s[maxn], ans[maxn]; int m…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1106 这个题目一开始以为是水题,就想着用来轻松轻松,谁知道改得我想吐!! 除了discuss 中的数据外,还加上这两组,一般就能过了:001568970056   5551235555789 #include <iostream> #include <cstring> #include <algorithm> using namespace std; + ; char s[…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 题目意思:有 N 颗星星,每颗星星都有各自的等级.给出每颗星星的坐标(x, y),它的等级由所有比它低层(或者同层)的或者在它左手边的星星数决定.计算出每个等级(0 ~ n-1)的星星各有多少颗. 我只能说,题目换了一下就不会变通了,泪~~~~ 星星的分布是不是很像树状数组呢~~~没错,就是树状数组题来滴! 按照题目输入,当前星星与后面的星星没有关系.所以只要把 x 之前的横坐标加起来就可以了…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 题目意思:有 本金 money,还有一些股票的种类,第 i 种股票买入需要 value[i] 这么多钱,相应会有一定的利息interest[i],问经过若干年 year 后,每年都以最优的方案投资,总的资金有多少? 完全背包题,不过要看清楚 这句话:The value of a bond is always a multiple of $1 000,否则TLE了 #include <iostr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2041 哦--对了,这些题读者可以直接忽略,我只是想练习一下自己薄弱的地方...... 题目意思我就不说了...自从昨晚问完乌冬兄一条DP题之后,“一体就知道系DP啦,而且仲好简单噶DP...”.就深感自己是如此地弱......可能有一段相当漫长的时间不会再找他了,毕竟一个喳喳对着一个区域赛银牌的人,自尊心作祟,而且,很大压力!我发现我好多不会......他好像以为我什么都会...... 这条题以前做…
Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6174    Accepted Submission(s): 3876 Problem Description You're in space.You want to get home.There are asteroids.You don't want to hit…
题意: 给出一个m叉树的前,后序遍历求这样的树有多少种. Solution: 我们知道前序遍历的第一个点一定是根节点,后序遍历的最后一个点一定是根节点. 由此,我们只一要确定对于每一个节点,它有多少个儿子节点,再累乘C(m,k). code #include <iostream> #include <algorithm> #include <string> using namespace std; string sq, sh; int len, ans,m; int C…
三维广搜 #include <cstdio> #include <iostream> #include <cstring> #include <queue> using namespace std; struct node { int x,y,z; int steps; }start,end,next; ]={,,,,,-}; ]={,,-,,,}; ]={,-,,,,}; ][][]; int n,res; bool check(node &a)…
普通的三维广搜,须要注意的是输入:列,行,层 #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #define M 11 using namespace std; int dir[6][3]={{0,1,0},{0,-1,0},{1,0,0},{-1,0,0},{0,0,1},{0,0,-1}};//6个方向 int…
题目链接:点击链接 简单BFS,和二维的做法相同(需注意坐标) 题目大意:三维的空间里,给出起点和终点,“O”表示能走,“X”表示不能走,计算最少的步数 #include <iostream> #include <stdio.h> #include <string.h> #include <queue> using namespace std; char map[11][11][11]; int v[11][11][11],d[6][3] = { {1,0,…
233 Matrix Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the quest…
Number Sequence Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Problem Description There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● a i ∈ [0,n] ● a i ≠ a j ( i…
Dice Time Limit:1000MS     Memory Limit:65536KB Description There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a 1.a 2,a 3,a 4,a 5,a 6 to be numbers written on top face, bottom face, left face, r…
Game Time Limit:1000MS     Memory Limit:65536KB Description Here is a game for two players. The rule of the game is described below: ● In the beginning of the game, there are a lot of piles of beads. ● Players take turns to play. Each turn, player ch…
Post Robot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K Problem Description DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog. But there is such few comments of his…
题意:给出一个三维的空间,给出起点和终点,问是否能够到达终点 和上一题一样,只不过这一题的坐标是zxy输入的, 因为题目中说的是接下来的n行中分别是由n*n的矩形组成的,所以第一个n该是Z坐标,n*n的矩形为底面,为x,y坐标 -----还是注意输入的方式--- #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #de…
HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj.red/contests/view/1155/1 题目描述 Kaguya Houraisan was once a princess of the Lunarians, a race of people living on the Moon. She was exiled to Earth over…