Hello every one  i tried to code the same problem using STL maps....but
getting the RUN TIME ERROR....
plz help in correcting my code....

#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int tc,i,t1,t2;
string s1,s2,ans;
map<string,int> tmap;
scanf("%d",&tc);
while(tc--)
{
    for(i=0;i<16;i++)
    {
        cin>>s1;
        cin>>s2;
        cin>>t1>>t2;
        if(t1>t2)
                tmap[s1]+=1;
        else
                tmap[s2]+=1;
    }
    //cout<<tmap["ger"];
    map<string,int>::iterator it;
    for(it=tmap.begin();it!=tmap.end();++it)
    {
        if(it->second==4)
                break;

    }
    if(it!=tmap.end())
    {
        ans=it->first;
    }

    if(tmap.end()->second=4)
    {
        ans=tmap.end()->first;
    }
    cout<<ans<<endl;
    tmap.erase(tmap.begin(),tmap.end());
}
return 0;
}




On Mon, Jun 6, 2011 at 11:23 AM, PRAMENDRA RATHi rathi
<prathi...@gmail.com>wrote:

> tnxxxxx all of u...what a foolish mistake i hd done....:P
>
>
> On Mon, Jun 6, 2011 at 10:38 PM, saurabh singh <saurab...@gmail.com>wrote:
>
>> Agree with logic king...Moreover have you thouht of using maps?That will
>> improove your code's efficiency(With respect to current code) and also make
>> it shorter,
>>
>> On Mon, Jun 6, 2011 at 5:12 PM, Logic King <crazy.logic.k...@gmail.com>wrote:
>>
>>> How can you assume that team name cannot be other than these.....where in
>>> the question is written that only these teams will constitute the last 16.
>>>
>>> i hope you got my point and your mistake as well !!
>>>
>>>   On Mon, Jun 6, 2011 at 4:28 AM, PRAMENDRA RATHi rathi <
>>> prathi...@gmail.com> wrote:
>>>
>>>>
>>>> no, i am getting wrong answer again with this logic..
>>>>
>>>> it is my code::
>>>>
>>>> int main()
>>>> {
>>>> register int test,i,j,winner=0,g1,g2;
>>>> string s1,s2;
>>>> string
>>>> team[16]={"ARG","BEL","BRZ","CAM","COL","CRC","CZE","ENG","GER","IRE","ITA","NET","ROM","SPA","URU","YUG"};
>>>>
>>>> cin >>test;
>>>> while(test--)
>>>> {
>>>> int point[16]={0};
>>>> for(j=0;j<16;j++)
>>>> {
>>>> cin>>s1>>s2>>g1>>g2;
>>>> if(g1>g2)
>>>> {
>>>>     for(i=0;i<16;i++)
>>>>     {
>>>>         if(s1==team[i])
>>>>         {point[i]++;break;}
>>>>     }
>>>> }
>>>> else
>>>> {
>>>>     for(i=0;i<16;i++)
>>>>     {
>>>>         if(s2==team[i])
>>>>         {point[i]++;break;}
>>>>     }
>>>> }
>>>>
>>>> }
>>>> int big=0;
>>>> for(i=0;i<16;i++)
>>>>
>>>> { cout<<"team "<<team[i]<<"::"<<point[i]<<endl;
>>>> if(point[i]==4){cout<<team[i]<<endl;break;}}
>>>>
>>>> }
>>>>
>>>> return 0;
>>>>
>>>> }
>>>>
>>>>
>>>> On Mon, Jun 6, 2011 at 1:49 PM, nicks <crazy.logic.k...@gmail.com>wrote:
>>>>
>>>>> @parmendra..yeah u r right what's ur problem u r not able to implement
>>>>> it r what....only winner will win 4 matches runner and 3rd posn will win 3
>>>>> match each...
>>>>>
>>>>>
>>>>> On Mon, Jun 6, 2011 at 12:47 AM, arun kumar <kumar0...@gmail.com>wrote:
>>>>>
>>>>>> any team which has nt lost a match will win
>>>>>>
>>>>>> On Mon, Jun 6, 2011 at 1:12 PM, PRAMENDRA RATHi rathi
>>>>>> <prathi...@gmail.com> wrote:
>>>>>> > i am thinking that the team with win point 4 will be the winner ..
>>>>>> > is this wrong?
>>>>>> >
>>>>>> > https://www.spoj.pl/problems/SBETS/
>>>>>> >
>>>>>> >
>>>>>> > because there are only 16 match 8+4+2+1(final) +1(for  runner up)
>>>>>> > so any team can play at max 4 match.
>>>>>> >
>>>>>> > --
>>>>>> > You received this message because you are subscribed to the Google
>>>>>> Groups
>>>>>> > "Algorithm Geeks" group.
>>>>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> > To unsubscribe from this group, send email to
>>>>>> > algogeeks+unsubscr...@googlegroups.com.
>>>>>> > For more options, visit this group at
>>>>>> > http://groups.google.com/group/algogeeks?hl=en.
>>>>>> >
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>> --
>>>>>  You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>> --
>>>>  You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>> --
>>>  You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>> --
>>  You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
>  You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to