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 1195. Ouths and Crosses

Hint
Posted by ASK 2 Mar 2010 15:39
Do not use the fact that there are only 3 moves left. The traditional minimax is fast and simpler to write.
Re: Hint
Posted by Anton 20 Dec 2011 10:24
Finally I decided to use your way and I got AC.
First of all, I cost tree leafs and then run minimax on the tree.
You did in the same way ?
On the leaf-costing I don't like how I find index for the child nodes. Is there a more beautiful way then in function below:

void costIt( char val=1, char pos = 2 ){
    char res = 0;
    for( char i = 0; i < 3; i++ ){
        if ( !arr[ f_x[ i ] ][ f_y[ i ] ] ){
            arr[ f_x[ i ] ][ f_y[ i ] ] = val;
            res = check();
            if ( res == 0 )
                costIt( val == 1 ? -1 : 1, pos*2+1 );
            else if ( !set[ pos > 10 ? (pos-1)/2 : pos ] ){
                cost[ pos > 10 ? (pos-1)/2 : pos  ] = res;
                set[ pos > 10 ? (pos-1)/2 : pos ] = true;
            }
            arr[ f_x[ i ] ][ f_y[ i ] ] = 0;
            pos++;
        }
    }
}

Edited by author 20.12.2011 10:24