10391 - Compound Words

The forum to report every bug you find or tell us what you'd like to find in UVa OJ's new system

Moderator: Board moderators

Locked
Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

10391 - Compound Words

Post by Leonid » Sun Nov 16, 2008 1:16 am

The problem statement states:

Code: Select all

A two-word compound word is a word in the dictionary that is the concatenation of EXACTLY TWO OTHER WORDS in the dictionary
But expected output for the test case:

Code: Select all

a
aa
Is

Code: Select all

aa
Please clarify the description and add the statement.

Code: Select all

Two other words may be identical!

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Re: 10391 - Compound Words

Post by newton » Mon Jan 05, 2009 5:22 pm

because two other words (substring) may be identical,
that means
"aa" = "a" + "a";

hope it help u.

Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

Re: 10391 - Compound Words

Post by Leonid » Thu Feb 05, 2009 3:39 am

newton wrote:because two other words (substring) may be identical,
that means
"aa" = "a" + "a";

hope it help u.
That's what I mean. But I think the problem description is not clear enough to make this implication so I'd suggest to add a sentence. "Concatenation can consist of the same word repeated twice (i.e. "two other words" may be the same word)".

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

Re: 10391 - Compound Words

Post by alamgir kabir » Sat Feb 14, 2009 12:43 am

I am getting TLE. please help me.

Code: Select all

#include<iostream>
#include<map>
#include<vector>
#include<string.h>

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    vector<string> str;
    char s [ 100 ];
    typedef map<string, int> d;
    long i, j, count = 0;
    d dir;
    while( gets( s ) )
    {
        if( dir.find( s ) == dir.end () )
        {
            dir.insert(d::value_type(s,0));
            str.push_back( s );
            count ++;
        }
    }
    for( i = 0; i < count ; i ++ )
    {
        for( j = 0; j < count ; j ++)
        {
            if( dir.find(str [ i ] + str [ j ] ) != dir.end() )
            {
                cout << str [ i ] + str [ j ] << '\n';
            }
        }
    }
    return 0;
}
Thanks everybody.

User avatar
Carlos
System administrator
Posts: 1286
Joined: Sat Oct 13, 2001 2:00 am
Location: Valladolid, Spain
Contact:

Re: 10391 - Compound Words

Post by Carlos » Sun Mar 22, 2009 6:01 pm

I think the description is clear enough.

About the TLE, please, ask for this kind of help in the right subforum "Volume 103".
DON'T PM ME --> For any doubt, suggestion or error reporting, please use the "Contact us" form in the web.

Locked

Return to “Bugs and suggestions”