10363 - Tic Tac Toe
Moderator: Board moderators
-
- Experienced poster
- Posts: 106
- Joined: Sun Feb 17, 2002 2:00 am
- Location: Seoul, South Korea
- Contact:
10363 - Tic Tac Toe
I don't know about this problem.
I think that I check only current tic-tac-toe status, and
if current status is correct ( i.e number of 'O' is equal or
one less than 'X' . if X is win then number of O is one less
than X, etc. ) then I print "yes".
But I receive "wrong answer". I'm really want to know about
solution. Anyone give me some hints?
I think that I check only current tic-tac-toe status, and
if current status is correct ( i.e number of 'O' is equal or
one less than 'X' . if X is win then number of O is one less
than X, etc. ) then I print "yes".
But I receive "wrong answer". I'm really want to know about
solution. Anyone give me some hints?
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
At first I try to use the condition to check, but failed.
But after reading your post, I find what condition I missed.
Here is the condition I check:
The numebr of X and O
no 2 people win same time
If anyone win at 2 different rows(columns) same time
If anyone win, check with the number of both sides.
But after reading your post, I find what condition I missed.
Here is the condition I check:
The numebr of X and O
no 2 people win same time
If anyone win at 2 different rows(columns) same time
If anyone win, check with the number of both sides.
-
- Learning poster
- Posts: 67
- Joined: Sun Sep 22, 2002 5:40 am
- Location: Taiwan
Tic Tac Toe confusing
[color=red]
One line of the problem's context is as follows:
Whenever X or O plays we fill in an X or an O in the "appropriate" position.
What is the word,"appropriate",means?
Is unoccupied or best way to win?
In such situation,what should be printed in the follow input case?
XOX
OXO
XOX
[/color]
One line of the problem's context is as follows:
Whenever X or O plays we fill in an X or an O in the "appropriate" position.
What is the word,"appropriate",means?
Is unoccupied or best way to win?
In such situation,what should be printed in the follow input case?
XOX
OXO
XOX
[/color]
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
"For each case print "yes" or "no" on a line by itself, indicating whether or not the configuration could be part of a Tic Tac Toe game."
I think that this means that not all moves has to be optimal, only each move has to be valid.
If you count the number of "X" and "O", it is sufficient to check if there is one winning position for "X" or for "O". It is only possible for "X" to have two winning positions like:
XXX
XOO
XOO
In these cases one can assume that the last "X" is placed at the position where the two rows/columns/diagonals intersect.
I think that this means that not all moves has to be optimal, only each move has to be valid.
If you count the number of "X" and "O", it is sufficient to check if there is one winning position for "X" or for "O". It is only possible for "X" to have two winning positions like:
XXX
XOO
XOO
In these cases one can assume that the last "X" is placed at the position where the two rows/columns/diagonals intersect.
-
- Learning poster
- Posts: 67
- Joined: Sun Sep 22, 2002 5:40 am
- Location: Taiwan
Thanks.
Tkanks for your helpful advise.mido.
I solve this problem during 0.00 second.
I solve this problem during 0.00 second.
-
- Experienced poster
- Posts: 106
- Joined: Sun Feb 17, 2002 2:00 am
- Location: Seoul, South Korea
- Contact:
Anyway, I finally know the solution.
In this problem, there are some obvious keys.
1) All of the input case is 3*3, consist of valid character.
2) So we should check whether current input status is valid or not.
3) Therefore, we count current number of O and X, and check
if O is win or X is win. ( As above article said that if current game
status is last one, then X can doubled in a row status. )
4) If current status is not last one, then O is equal or one less than
number of X.
So we should only
i)count X and O's number
ii) X is win or O is win.
It's sufficient to solve this poroblem.
In this problem, there are some obvious keys.
1) All of the input case is 3*3, consist of valid character.
2) So we should check whether current input status is valid or not.
3) Therefore, we count current number of O and X, and check
if O is win or X is win. ( As above article said that if current game
status is last one, then X can doubled in a row status. )
4) If current status is not last one, then O is equal or one less than
number of X.
So we should only
i)count X and O's number
ii) X is win or O is win.
It's sufficient to solve this poroblem.
What I do is just like this
1. count the number of valid O and X overall
2. count the number of valid O and X if O win
3. count the number of valid O and X if X win
4. count the number of valid O and X if neither win
and it's accepted, but PE, I'm confused , where should I put the extra
blank line in this problem??????
1. count the number of valid O and X overall
2. count the number of valid O and X if O win
3. count the number of valid O and X if X win
4. count the number of valid O and X if neither win
and it's accepted, but PE, I'm confused , where should I put the extra
blank line in this problem??????