TicTacToe3D
SRM 121 · 2002-11-26 · by mitalub
SRM 121 · 2002-11-26 · by mitalub
Problem Statement
Problem Statement
Given n, return the number of distinct ways to put n X's on an n by n by n 3-D Tic Tac Toe Board such that the n X's are in a row.
The n in a row can be in a horizontal, vertical, or diagonal line.
Constraints
- n will be between 1 and 1000, inclusive.
Examples
0)
1 Returns: 1
There is only one possible place to put the X, and it results in getting 1 in a row, so there is 1 way to get 1 in a row.
1)
2 Returns: 28
2)
8 Returns: 244
3)
500 Returns: 753004
4)
1000 Returns: 3006004
Submissions are judged against all 25 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class TicTacToe3D with a public method int howMany(int n) · 25 test cases · 2 s / 256 MB per case