Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14677    Accepted Submission(s): 4653Special Judge Problem Description The Princess has been abducted by the BEelzebub…
题目链接 题意 : 从(0,0)点走到(N-1,M-1)点,问最少时间. 思路 : BFS..... #include <stdio.h> #include <string.h> #include <queue> #include <iostream> using namespace std ; struct node { int x,y ; int tim ; friend bool operator < (node a,node b) { retu…
Ignatius and the Princess I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he g…
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10541    Accepted Submission(s): 3205Special Judge Problem Description The Princess has been abducted by the BEelzebub…
题意: N=a[1]+a[2]+a[3]+...+a[m];  a[i]>0,1<=m<=N; 例如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 共有5种. 给N,问共有几种构造方式. 思路: 一个数N分解的式子中1的个数可以是0,1,2,3,...,N. 2的个数可以是0,1,2,...,N/2. .... 母函数基础题,, 看代码. 当然也可以用DP(背包) 母函数代码: int N,num;…
  此题需要时间更少,控制时间很要,这个题目要多多看, Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9910    Accepted Submission(s): 2959 Special Judge Problem Description The Princess has b…
http://acm.hdu.edu.cn/showproblem.php?pid=1026 题意:给出一个迷宫,求出到终点的最短时间路径. 这道题目在迷宫上有怪物,不同HP的怪物会损耗不同的时间,这个时候可以用优先队列,每次让时间最短的出队列.由于最后还需要输出路径,所以需要设置一个数组来保存路径. #include<iostream> #include<queue> #include<cstring> using namespace std; + ; struct…
题目链接 Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth. To make the problem simply, we assume the lab…
以前写的题了,现在想整理一下,就挂出来了. 题意比较明确,给一张n*m的地图,从左上角(0, 0)走到右下角(n-1, m-1). 'X'为墙,'.'为路,数字为怪物.墙不能走,路花1s经过,怪物需要花费1s+数字大小的时间. 比较麻烦的是需要记录路径.还要记录是在走路还是在打怪. 因为求最短路,所以可以使用bfs. 因为进过每一个点花费时间不同,所以可以使用优先队列. 因为需要记录路径,所以需要开一个数组,来记录经过节点的父节点.当然,记录方法不止一种. 上代码—— #include <cst…
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(~scanf("%d",&n)){ int x,ans,cnt = 0; while(n--){ scanf("%d",&x); if(cnt == 0){ ans = x; cnt++; }else{ if(x == ans) cnt++; else cnt--; } } printf("…