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

Common Board

Is anybody can give me the TEST#6 for problem 1022
Posted by PoiXP 10 Aug 2005 16:47
I WA on 6-th test.
If your can please send me to kilobyte@nm.ru
Re: Is anybody can give me the TEST#6 for problem 1022
Posted by ACM.Krupko_Victor[Ivanovo SPU] 10 Aug 2005 18:51
It is known only by the GOD and pair administrators.
Show the code and people will help you.
Re: Is anybody can give me the TEST#6 for problem 1022
Posted by PoiXP 10 Aug 2005 19:06
here is the code:

#include <iostream>
using namespace std;
//-------------------------------------------------
class TStack
{
public:
    TStack* Insert(int Value);
    TStack* Add(int x);
    TStack * Next;
    int Value;
    TStack();
};
bool Find(int Value, TStack *ptr);
void deleteStack(TStack *ptr);
//-----------------------------------------------------
int main()
{
    TStack * Head = new TStack();
    TStack * ptr;
    ptr = Head;
    int N;
    cin >> N;
    for(int i=0;i<N;i++)
    {
        TStack * HeadArray = new TStack();
        TStack * ptrArray = HeadArray;
        int Ai;
        cin >> Ai;
        while(Ai != 0)
        {
            ptrArray = ptrArray->Add(Ai);
            cin >> Ai;
        }
        ptr = Head;
        bool flag = true;
        while(flag)
        {
            if(i == 0)
            {
                ptr->Add(i+1);
                flag = false;
            }
            else
            {
                bool change = true;
                while(ptr->Next != NULL && change)
                {
                    ptrArray = HeadArray;
                    if(Find(ptr->Next->Value,ptrArray))
                    {
                        ptr->Insert(i+1);
                        change = false;
                    }
                    else
                    {
                        ptr = ptr->Next;
                    }
                }
                if(change)
                {
                    ptr->Add(i+1);
                }
                flag = false;
            }
        }
        deleteStack(HeadArray);
    }
    ptr = Head->Next;
    while(ptr != NULL)
    {
       cout << ptr->Value << " ";
       ptr = ptr->Next;
    }
    deleteStack(Head);
    cin >> N;
    return 0;
};
//------------------------------------------------------
bool Find(int Value, TStack *ptr)
{
    bool result = false;
    while(ptr != NULL && !result)
    {
        if(ptr->Value == Value) result = true;
        else
        {
            ptr = ptr->Next;
        }
    }
    return result;
}
//-----------------------------------------------------
TStack::TStack()
{
    Next = NULL;
    Value = 0;
}
//-----------------------------------------------------
TStack* TStack::Add(int x)
{
    TStack * ptrValue = new TStack();
    ptrValue->Value = x;
    Next = ptrValue;
    return ptrValue;
}
//------------------------------------------------------
TStack* TStack::Insert(int Value)
{
    TStack *ptrValue = new TStack();
    ptrValue->Value = Value;
    ptrValue->Next = Next;
    Next = ptrValue;
    return ptrValue;
}
//---------------------------------------------------------
void deleteStack(TStack *ptr)
{
     while(ptr != NULL)
     {
        TStack *ptrBuff = ptr;
        ptr = ptr->Next;
        delete ptrBuff;
     }
     return;
}
EXCUSE I DO NOT KNOW "C"
Posted by ACM.Krupko_Victor[Ivanovo SPU] 10 Aug 2005 22:39