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 1871. Seismic Waves

test 2
Posted by alex kichkin 18 Oct 2011 23:25
could you tell me what is the test #2? I'm trying to find mistake in my solution but it doesn't work at all; my own tests are succses

Edited by author 18.10.2011 23:27
Re: test 2
Posted by Gao Yang 19 Oct 2011 07:52
Pay attention to that the one can't retweet the message but he has learn it.
Re: test 2
Posted by alex kichkin 20 Oct 2011 01:00
thank you so much! but one more question...
if the fist one tweets "aaaaa earthquake!!!!", the second retweets "RT @name1: aaaaa earthquake!!!!" what should write the third one who wants to retweet: "RT @name2: aaaaa earthquake!!!!" or "RT @name2: RT @name1: aaaaa earthquake!!!!"
Re: test 2
Posted by Gao Yang 20 Oct 2011 08:17
If the third one retweet the second one's message, should be your second expression "RT @name2: RT @name1: aaaaa earthquake!!!!" ,or if he retweet the first one's message, should be
"RT @name1: aaaaa earthquake!!!!" . If both retweet for the third one is legal, choose the shorter one is fine.
Re: test 2
Posted by alex kichkin 20 Oct 2011 21:22
ok thank you:)))
Re: test 2
Posted by Vavan 21 Oct 2011 23:53
        ""Послано Gao Yang 19 октября 2011 07:52
         Pay attention to that the one can't retweet the message but he has learn it.""

Please, give this test.

Edited by author 21.10.2011 23:54

Edited by author 21.10.2011 23:55
Re: test 2
Posted by Vavan 21 Oct 2011 23:54
Please, give this test.
Where are bugs? =)

#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

class my_less{
    public:
        bool operator()( const pair<string,short> a, const pair<string,short> b ){
            return a.second < b.second;
        }
};

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
    #endif
    map<string,bool> DidGet;
    map<string,short> minLengthMessage;
    map< string, set<string> > users;
    set<string> informed;//опповещёные
    long n;
    string first_man;
    cin >> n;
    for( short i = 0; i < n; ++i ){
        //cout << i << endl;
        string name;
        cin >> name;
        users[name] = set<string>();
        if( !i ) first_man = name;
        DidGet[name] = false;
        minLengthMessage[name] = numeric_limits<short>::max();
        long kol;
        if( scanf("%ld", &kol)!=1 ){while(1)printf("12121");};
        for( long j = 0; j < kol; ++j ){
            string follower;
            cin >> follower;
            users[name].insert( follower );
        }
    }
    //for(map< string, set<string> >::iterator i = users.begin();
    //    i != users.end();
    //    ++i
    //) {
    //    cout << (*i).first << endl;
    //        for(
    //            set<string>::iterator it = (*i).second.begin();
    //            it != (*i).second.end();
    //            ++it
    //        )
    //        {
    //            cout << "    " << (*it) << endl;
    //        }
    //}
    string SOS_massage;
    while( cin.get() != '\n' );
    getline( cin, SOS_massage );
    if( SOS_massage.size() == 0 || SOS_massage.size()>140 ){while(1)puts("1212");}
    //cout << "|" << SOS_massage << "|" << endl;
    multiset< pair<string,short>, my_less > Q;
    Q.insert( pair<string,short>(first_man,SOS_massage.size()) );
    while( !Q.empty() ){
        pair<string,short> para = *Q.begin();
        Q.erase( Q.begin() );
        //cout << "Take:" << para.first << " " << para.second << endl;
        if( para.second <= 140
            &&( !DidGet[para.first] || minLengthMessage[para.first] > para.second)
        )
        {
            informed.insert( para.first );
            DidGet[para.first] = true;
            minLengthMessage[para.first] = para.second;
            //cout << "adding for: " << para.first << endl;
            for(
                set<string>::iterator it = users[para.first].begin();
                it != users[para.first].end();
                ++it
            )
            {
                //cout << "    " << *it << endl;
                Q.insert( pair<string,short>(
                    *it,
                    6 + para.first.length() + para.second//
                    //доп. симв. + длина имени отправителя + длина сообщ. которое получил отправитель
                ));//
            }
        }
    }
    cout << informed.size() << endl;
    for(
        set<string> ::iterator it = informed.begin();
        it != informed.end();
        ++it
    )
        cout << *it << endl;
    return 0;
}

Edited by author 22.10.2011 00:31
Re: test 2
Posted by IgorKoval(from Pskov) 23 Oct 2011 02:07
6
0000000000000000000            2 2222222222222222222222222222 55555555555555555555555555555
111111111111111111111111111111 2 0000000000000000000 2222222222222222222222222222
2222222222222222222222222222   1 55555555555555555555555555555
33333333333333333333333333     4 0000000000000000000 111111111111111111111111111111 2222222222222222222222222222 55555555555555555555555555555
4444444444444444444444444444   4 0000000000000000000 111111111111111111111111111111 33333333333333333333333333 55555555555555555555555555555
55555555555555555555555555555  4 0000000000000000000 111111111111111111111111111111 2222222222222222222222222222 33333333333333333333333333
LOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLOLO

answer:
3
0000000000000000000
2222222222222222222222222222
55555555555555555555555555555

this test isn't correct in names of Japanese. =)