hdu 5578 Friendship of Frog】的更多相关文章

Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5578 Description N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance betwee…
Problem Description N frogs . Two frogs are friends if they come from the same country. The closest friends are a pair of friends with the minimum distance. Help us find that distance. Input First line contains an integer T, which indicates the numbe…
题意:给定一行字符串(都是小写字母),每一个字符都代表一只青蛙以及其国籍,若字符串中出现两个字符相同,则这两个字符所代表的青蛙来自同一国度,可称之为好朋友. 现在需要找到距离最近的好朋友并输出他们的距离. 思路:建立一个map映射表,映射关系为:字符<->字符所在字符串的位置,从字符串头部到尾部依次进行扫描,每扫到一个字符,可以找一找map表中有没有出现该字符,若没出现过则在 表中建立这个字符的关系,若map表中有该字符的记录,那么说明当前字符串代表的青蛙找到了一个朋友,可以计算他与朋友的距离…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5578 Friendship of Frog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 556    Accepted Submission(s): 355 Problem Description N frogs from differe…
Friendship of Frog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 135    Accepted Submission(s): 106 Problem Description N frogs from different countries are standing in a line. Each country i…
题 题意 求相同字母最近距离 分析 用数组保存各个字母最后出现的位置,维护最小距离. 代码 #include <cstdio> int c[30],n,p,a,minl; char ch; int main(){ scanf("%d ",&n); for(int i=1;i<=n;i++){ for(int j=0;j<27;j++)c[j]=0; p=1;minl=2000; while((ch=getchar())!='\n'){ a=ch-'a';…
5573 Binary Tree(构造) 题意:给你一个二叉树,根节点为1,子节点为父节点的2倍和2倍+1,从根节点开始依次向下走k层,问如何走使得将路径上的数进行加减最终结果得到n. 联想到二进制. 思路和这个差不多吧:http://blog.csdn.net/u013068502/article/details/50094561 #include <set> #include <queue> #include <cstdio> #include <vector…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004 The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over…
Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 277    Accepted Submission(s): 192 Problem Description One day, Mr. Frog is playing Link Game (Lian Lian Kan in Chinese).In this g…
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 312    Accepted Submission(s): 219 Problem Description One day, you, a clever boy, feel bored in your math class, and then fall…