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 1433. Diamonds

Strange algo for solving this problem
Posted by Sergiy_PMI_LNU 28 Jul 2006 12:23
There is some strange algo, but AC.
let we have two arrays of char[5];
Then we compare first diamond with SOME permutations of second, but that permutations is 1234 1342 1423 2143 2314 ... i.e. we miss two permutations of lexicographic sequence of all permutations, the take two, then miss two again.
    int compare_condition = 1;
    while (1)
    {
        if (compare_condition < 2) compare(diamond1, diamond2);
        if (eq){
            cout << "equal" << endl;
            return 0;
        }
        compare_condition++;
        compare_condition %= 4;
        if (!next_permutation(p.begin(), p.end())) break;
    }
This code works, but why???
Can anybody prove it???
Strange algo, isn't???
Re: Strange algo for solving this problem
Posted by ILIA 18 Dec 2007 21:11
ATTENTION, PEOPLE! IT IS WRONG !!!


Edited by author 18.12.2007 21:12
Re: Strange algo for solving this problem
Posted by ILIA 18 Dec 2007 21:13
WA#12
Re: Strange algo for solving this problem
Posted by Denis Koshman 26 Jul 2008 23:32
Strange indeed :)))