我的错因: 本来改用%f输出,我用了%lf,结果编译器直接判定为错误(一部分编译器认为lf是没有错的).当时我还以为是hash出错了.. 方法不止一种: 方法 时间   空间 Hash 891ms 596k map<string,int> 2735ms   1316k sort 5000ms+ 30000k+ %lf 与 %f的具体区别: printf的%f说明符的确既可以输出float型又可以输出double型.根据"默认参数提升"规则float型会被提升为double型…
题目链接: 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…
                                                 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…
职务地址:id=2418">POJ 2418 通过这个题查了大量资料..知道了非常多曾经不知道的东西. . .. 在代码中凝视说明吧. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h&g…
Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 17986   Accepted: 7138 Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nut, and generally go dormant in the winter.  Amer…
题目: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;//声明迭代器…
1.输入若干行树名,输入结束后,按字典序输出树名及其所占百分比. 2.多种方法:map,trie,BST 3. map: #include<iostream> #include<stdio.h> #include<string> #include<map> using namespace std; int main(){ map<string,int>h; string s; int n; n=; while(getline(cin,s)){ +…
题目传送门 题意:输入一大堆字符串,问字典序输出每个字符串占的百分比 分析:二叉搜索树插入,然后中序遍历就是字典序,这里root 被new出来后要指向NULL,RE好几次.这题暴力sort也是可以过的... //#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> using namespace std; struct BST { char name…
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct AVLTree{ char name[31]; int nCount; int nHeight; struct AVLTree* pLeft; struct AVLTree* pRight; }AVLTree; int Max( int a, int b ); int Heig…
<题目链接> 题目大意: 给你一堆字符串,让你按字典序输出他们出现的频率. 解题分析: 首先,这是Trie数词频统计的题目,以Trie树的边储存字母,节点存储以该节点结尾的链所代表的字符串的数量,最后用dfs寻找Trie树中所有的单词,下面代码是用数组实现的Trie树.当然,本题也可用快排或者map直接水过. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm…
                                                     Hardwood Species Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nu…
简单字典树. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 128 typedef struct Trie { int count; Trie *next[MAXN]; Trie() { count = ; ; i<MAXN; ++i) next[i] = NULL; } } Trie; Trie root; ]; ; void create(char str[]) { ,…
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…
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 20619 Accepted: 8083 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…
Time Limit:10000MS    Memory Limit:65536KB    64bit IO Format:%I64d & %I64u SubmitStatus 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 temperat…
Hardwood Species DescriptionHardwoods 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 tha…
解题报告 Tire树. #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; struct node { int v; node *next[256]; }; int cnt=0,q; char ch[100],str1[100]; node *newnode() { node *p=new node; p->…
1. Hardwood Species原题描述   Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 14326   Accepted: 5814 Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nut, and generally go dormant in the wint…
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 21845 Accepted: 8551 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…
洛谷 UVA10226 Hardwood Species 洛谷评测传送门 题目描述 PDF 输入格式 输出格式 输入输出样例 输入 #1复制 输出 #1复制 题目翻译: 给定若干字符串,输出格式为:(按字典序)给出的字符串+这个字符串出现次数在给定字符串总数之中的占比. 注意:多组数据. 题解: 介绍三种东西: 第一种--字符串忽略空格只考虑回车的输入方式. 第二种--\(C++\,\,STL\,\,map\)容器. 第三种--字典树. 第一种: 字符串忽略空格只考虑回车的输入方式. 代码如下:…
1.C++字符串与C字符串的转换: (1)string --> char * string str("OK"); strcpy(p,str.c_str());//p是char* (2)char * -->string char p[] = "OK"; string str(p);  <=>  str=p; 2.数字转化为C字符串     使用sprintf()函数: char str[10]; int a=1234321; sprintf(s…
题目链接: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 #include<cstdio> #include<cstring> #include<string> #include<iostream> #include<map> #include<algorithm> using namespace std; ]; int main(){ //freopen("sb.txt","r",stdi…
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…
http://poj.org/problem?id=2418 题意:给定一系列字符串,要求按字典序升序输出每个串,并输出每个串出现的百分比. 用map做的,交c++A了,G++ WA..so sad..后来发现是输出格式写错了,现在改过来了.. #include <stdio.h> #include <iomanip> #include <algorithm> #include <iostream> #include <string.h> #in…
Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number of different substrings of a given size that exist in the text. As…
题意很明确,统计各个字符串所占总串数的百分比,暴力的话肯定超时,看了书上的题解后发现这题主要是用二叉排序树来做,下面附上n种树的代码. 简单的二叉排序树,不作任何优化(C语言版的): #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct node{ ]; struct node *lchild, *rchild; int count; }node; node *root= NULL;…
题目大意:给出n棵树(有重复),统计每种树出现的频率.使用STL的map. #include <cstdio> #include <iostream> #include <map> #include <string> #include <iomanip> #include <algorithm> using namespace std; typedef map<string, int> msi; int main() {…
http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=203#problem/B 属于暴力 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include <queue> #include <string>//string在这个头文件里: #include &…