Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

what the hell

Posted by juliustayl at 2013-03-06 14:02:54 on Problem 2418
I keep getting "Wrong Answer" for the code below....I have tested over and over and the output i am getting seems to be correct.  any suggestions?


//HARDWOOD SPECIES  PROBLEM 2418

#include <stdio.h>
#include <string>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

int main(void)
{
    int total = 0;
    int index = 0;
    typedef map<std::string, int> NewMap;
    NewMap treeList;
    std::string str[10000];
    char tname[31];
    
    while(scanf(" %[^\n]",tname)!=EOF){    
	if (treeList.count(tname)==0){
		str[index].assign(tname, tname + strlen(tname));
        	++treeList[str[index]];
        	index++;
        }
        else
        	++treeList[tname];
        	
        index++;
        total++;      
    }
    
    NewMap::iterator it_type;
    for(it_type  = treeList.begin(); it_type != treeList.end(); it_type++)
    {
	printf("%s %.4lf\n",it_type->first.c_str(),100*(double)(it_type->second)/total);
    }

    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator