POJ 2418】的更多相关文章

职务地址:id=2418">POJ 2418 通过这个题查了大量资料..知道了非常多曾经不知道的东西. . .. 在代码中凝视说明吧. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h&g…
题目链接:http://poj.org/problem?id=2418 题意:给定一堆树的名字,现在问你每一棵树[无重复]的出现的百分比,并按树名的字典序输出 思路:最简单的就是用map来写,关于字典树的解法,因为字典序的先序遍历是排序的,所以只需建好树后先序遍历一下树就可以满足题目要求的输出方式了. 坑点:树名会出现空格,而且题目也没说明可能出现的字符集合,所以树的孩子结点要有128个. G++无限WA换C++就能AC,这个无解... map: #define _CRT_SECURE_NO_D…
http://poj.org/problem?id=2418 这是一个二叉树的题目,但我看了下书,还是不是特别理解会用二叉树,所以我就用其他的办法来做,结果一样AC,时间也就1700多ms,比起二叉树的时间多了几百ms 但是就是内存大了很多倍,因为数组开的大,也是一个水题 题意就是给你很多个单词,要你统计单词出现的次数,最后按字典升序输出,题目还是比较简单的 #include <stdio.h> #include <iostream> #include <string.h&g…
题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器. c++ AC代码,G++为超时,上代码: #include<cstdio> #include<string> #include<map> using namespace std; ]; int main() { map<string,int>mp; map<string,int>::iterator iter;//声明迭代器…
http://poj.org/problem?id=2418 [注意] 1. 输入有空格,用 char str[maxn]; while(gets(str)){ str[]!='\0'; } 或 string str; while(getline(cin,str)&&!(str=='')){ } 2. char str[maxn]; string s; s=str; 而不是 char str[maxn]; string s; int len=strlen(str); ;i<len;i…
题目链接: id=2418">http://poj.org/problem?id=2418 Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 17511   Accepted: 6949 Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or n…
Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nut, and generally go dormant in the winter.  America's temperate climates produce forests with hundreds of hardwood species -- trees that share certain…
题目传送门 题意:输入一大堆字符串,问字典序输出每个字符串占的百分比 分析:二叉搜索树插入,然后中序遍历就是字典序,这里root 被new出来后要指向NULL,RE好几次.这题暴力sort也是可以过的... //#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> using namespace std; struct BST { char name…
                                                 Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16056   Accepted: 6418 Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or n…
题意很明确,统计各个字符串所占总串数的百分比,暴力的话肯定超时,看了书上的题解后发现这题主要是用二叉排序树来做,下面附上n种树的代码. 简单的二叉排序树,不作任何优化(C语言版的): #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct node{ ]; struct node *lchild, *rchild; int count; }node; node *root= NULL;…