Page 1 of 1

844 - Pousse

Posted: Sun Dec 03, 2006 6:46 am
by helloneo
Hello..~
Can anybody see anything wrong..?
I'm getting WAs..

Code: Select all

code removed

Posted: Sun Dec 03, 2006 12:30 pm
by Jan
I think you haven't understood the problem properly. The problem states
all markers on the insertion row or column from the insertion square upto the first empty square are moved one square further to make room for the inserted marker

Code: Select all

Suppose after playing a while you get the following state
  _______________ 
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 | O | O | X |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|

 Now if player 'X' uses move 'L2'
  _______________ 
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 | X | O | O | X |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|

 Now if player 'O' uses move 'T3'
  _______________ 
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 | X | O | O | X |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|

 Now if player 'X' uses move 'L2'
  _______________ 
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 | X | X | O | O |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | X |   |
 |___|___|___|___|

 Now if player 'O' uses move 'T3'
  _______________ 
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 | X | O | O | X |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|
 |   |   |   |   |
 |   |   | O |   |
 |___|___|___|___|

 And at this stage 'O' has one straight, but 'X' has none. So, 'O' Wins.
Hope it helps.

Posted: Sun Dec 03, 2006 3:00 pm
by helloneo
AC..
Thanks a lot :-)

Re: 844 - Pousse

Posted: Thu Jan 24, 2019 4:06 pm
by metaphysis
Test data generator.

Code: Select all

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
    srand(time(NULL));
    int cases = 100;
    cout << cases << "\n\n";
    
    for (int cs = 1; cs <= cases; cs++)
    {
        if (cs > 1) cout << '\n';
        int N = rand() % 101;
        cout << N << '\n';
        string push = "LRTB";
        for (int i = 1; i <= 100 && N; i++)
        {
            cout << push[rand() % 4];
            cout << rand() % N + 1;
            cout << '\n';
        }
        cout << "QUIT\n";
    }

    return 0;
}