|
|
back to boardThere 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??? ATTENTION, PEOPLE! IT IS WRONG !!! Edited by author 18.12.2007 21:12 |
|
|