Page 3 of 3

Posted: Thu Sep 06, 2007 6:51 pm
by ayon
most probably online-judge doesn't support clear()

Posted: Thu Sep 06, 2007 6:55 pm
by lena
ayon wrote:most probably online-judge doesn't support clear()
could somebody give a specification on the environment of online-judge?

Posted: Fri Sep 07, 2007 1:00 pm
by Krzysztof Duleba
ayon wrote:most probably online-judge doesn't support clear()
It does.

std::string comes from <string>, not from <cstring> (although you need the latter for strcmp (although operator== could do the trick with much less typing)).

Posted: Tue Sep 11, 2007 8:57 am
by lena
solved.thank you.when i didnot include the <string> library,the compiler didnot give any warning...,so i submit a wrong code.

Wrong answer.....10126

Posted: Wed Mar 05, 2008 8:50 am
by mirage
hi friends,
i m gettin wrong answer on the OJ for this easy prob........the program is passing the test that i gave it n the one ones i found in the forums.....
still unable to find the bug....plz help......
is thr any special way to print the output for this prob...
here's the code:

Code: Select all

//Zipf's law 
#include<iostream> 
#include<map> 
#include<string> 
using namespace std; 
int main(){ 
   int n; 
   int count=0; 
   while(cin>>n){ 
      if(count++!=0) cout<<"\n"; 
      string s; 
      int loop=1; 
      map<string,int> maps; 
      while(loop==1){    
         getline(cin,s,'\n'); 
         s=s+" ";    
         int i=0; 
         while(i<s.length()){ 
            string h=""; 
            int val=s[i]; 
            string alias=""; 
            while((val>=65 && val<=90)|| (val>=97 && val<=122)){ 
               if(val>=90) h=h+s[i]; 
               else h=h+char(s[i]+32); 
               alias=alias+s[i++]; 
               val=s[i]; 
            } 
            i++; 
            if(alias=="EndOfText"){ 
               loop=0; 
               break; 
            } 
            maps[h]=maps[h]+1; 
         } 
      } 
      map<string,int>::iterator iter; 
      iter=maps.begin(); 
      int l=0; 
      while(iter!=maps.end()){ 
         if(iter->second==n) { 
            cout<<iter->first<<"\n"; 
            l=1; 
         } 
         iter++; 
      } 
      if(l==0) cout<<"There is no such word."<<"\n"; 
      maps.clear(); 
   } 
   return(0); 
} 

Re: 10126 - Zipf's Law

Posted: Sat Oct 10, 2009 11:37 am
by Jehad Uddin
read the problems output specification,
For each test case, output the words which occur n times in the input text, one word per line, lower case, in alphabetical order

Re: 10126 - Zipf's Law

Posted: Sat May 19, 2012 1:54 pm
by sd12582000
try
input
2
a-a
EndOfText
output
a