ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1700. Awakening

TL on test 9.I use C++ with STL.
Posted by Narek X 17 Nov 2009 18:02
Re: TL on test 9.I use C++ with STL.
Posted by melkiy 17 Nov 2009 19:29
Do not make many copies of strings where you can use only pointers on them.
Re: TL on test 9.I use C++ with STL.
Posted by Narek X 17 Nov 2009 20:57
Here is my code.
I think that all is good.
Please help me.
I am studing STL and I want solve this problem with STL.

#pragma warning (disable:4786)
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    map<string,set<string, less <string> >, less<string> > mp;
    set<string, less <string> >::iterator it,end;
    int m,n,i,j,q,minidx,min;
    bool t;
    string vec[126],str;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>str;
        str.erase(str.length()-1,str.length());
        q=0;
        while(cin.peek()!='\n')
        {
            cin>>vec[q];
            q++;
        }
        mp[str].insert(vec,vec+q);
    }
    cin>>m;
    for(i=0;i<m;i++)
    {
        minidx=0;
        min=1000000;
        q=0;
        cin.ignore();
        while(cin.peek()!='\n' && !cin.eof())
        {
            cin>>vec[q];
            if(mp[vec[q]].size()<min)
            {
                min=mp[vec[q]].size();
                minidx=q;
            }
            q++;
        }
        end=mp[vec[minidx]].end();
        t=false;
        for(it=mp[vec[minidx]].begin();it!=end;it++)
        {
            for(j=0;j<q && mp[vec[j]].find(*it)!=mp[vec[j]].end();j++);
            if(j==q)
            {
                cout<<*it<<' ';
                t=true;
            }
        }
        if(!t)
            cout<<"No solution.";
        cout<<endl;
    }
    return 0;
}

Edited by author 17.11.2009 21:00