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 1003. Parity

impossible :)
Posted by Mikhail Rubinchik[USU][Kungur] 13 Nov 2009 01:31
How can find difference in two codes?



----------------------1-------------------------

void addVertex(int & a)
{
    bool find = false;
    int len = v.size();
    int k = 0;
    for(int i = 0; i < len; i++)
    {
        if(v[i] == a)
        {
            a = i;
            k++;
            find = true;
        }
    }
    if(k > 1)
    {
        //throw 42;
    }
    if(!find)
    {
        v.push_back(a);
        a = v.size() - 1;
        part[a] = partNumber++;
    }
}



------------------------------2----------------------

void addVertex(int & a)
{
    int len = v.size();
    for(int i = 0; i < len; i++)
    {
        if(v[i] == a)
        {
            a = i;
            return;
        }
    }
    v.push_back(a);
    a = v.size() - 1;
    part[a] = partNumber++;
}

If I use second function I get AC, but if I use first function I get WA 1. If in first add string "throw 42" then I get Crash 1.

I use vector "v" only in this function.