Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results312 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Stone Game 5Two players alternately take 1 or 3 stones from a pile of N, and the program prints SK or CY for optimal play.Easy2Game theoryMathNo attempts yet1s128 MBJudgeable
Towers of CoinsGiven move options 1, K, or L coins in a Nim-like turn game, determine for each pile size whether the first player wins under optimal play.Easy3Dynamic programmingGame theoryNo attempts yet1s128 MBJudgeable
The Stone GamePlayers alternately remove 1 to K of N stones, and the player taking the last stone wins each test case.Easy3Game theoryMathNo attempts yet1s128 MBJudgeable
Stone GameTwo players alternately take 1 or 3 stones from a pile of N, and the program names the winner under perfect play.Easy3Dynamic programmingGame theoryNo attempts yet1s128 MBJudgeable
Stone Game 2Two players alternately take 1 or 3 stones from a pile of N and the player taking the last stone loses, so print whether the first player wins.Easy3Game theoryDynamic programmingNo attempts yet1s128 MBJudgeable
Stone Game 3Two players alternately take 1, 3, or 4 stones from a pile of N, and the program reports whether the first player wins with perfect play.Easy3Dynamic programmingGame theoryNo attempts yet1s128 MBJudgeable
Stone Game 4Two players alternately take 1, 3, or 4 stones and the player taking the last stone loses; report whether the first player wins with optimal play.Easy3Dynamic programmingGame theoryNo attempts yet1s128 MBJudgeable
Stone Game 6Two players alternately take 1, 3, or 4 stones from a pile of N, and the program prints which player wins with perfect play.Easy3Game theoryDynamic programmingNo attempts yet1s128 MBJudgeable
Falling ApartGiven up to 15 positive integers, two players alternately take one piece; find the final sums under optimal play.Easy3Dynamic programmingGame theory+1No attempts yet2s512 MBJudgeable
Alpha Tic-Tac-ToeGiven a 3x3 tic-tac-toe board with X to move or O to move, find whether the side to move can force a win, a draw, or only a loss under perfect play.Easy3Game theoryRecursion+1No attempts yet1s256 MBJudgeable
Marble GameCompute Grundy-style win/lose states for a two-pile subtraction game with three fixed move sizes and report the winner for five given starting positions.Medium4Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
JohnDetermine the winner of a Nim-like misère game where players remove same-colored candies from piles and taking the last candy loses.Medium4Game theoryBit manipulation+1No attempts yet1s128 MBJudgeable
PousseSimulate the push game on an N by N board and report which color first has more complete rows or columns, or a tie at QUIT.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
Tic Tac ToeGiven a 3x3 Tic Tac Toe grid, decide whether some legal sequence of moves could produce exactly that position.Medium4ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Card GameBoth players alternately take the left or right end card to maximize their own sum, and you compute the first player best total score.Medium4Dynamic programmingGame theoryNo attempts yet1s256 MBJudgeable
Box Splitting GameDecide whether the first or second player wins the two-box stone-splitting game from starting counts N and M.Medium4Game theoryDynamic programmingNo attempts yet2s512 MBJudgeable
Nim Game 2Two players alternately remove stones from one of N piles and the player taking the last stone wins, so decide the winner under optimal play.Medium4Game theoryBit manipulationNo attempts yet2s512 MBJudgeable
WhistGiven the trump suit and the 52 cards played across 13 tricks, determine which team won and by how many tricks above six.Medium4SimulationImplementation+1No attempts yet8s512 MBJudgeable
Irrational DivisionTwo players alternately cut whole columns off the west and rows off the south of a p by q chessboard chocolate; compute the optimal final score difference.Medium4Game theoryDynamic programmingNo attempts yet2s512 MBJudgeable
Jogo de BocaGiven the target N, decide whether the first player can win the 1-2 counting game and which opening move (1 or 2) wins.Medium4Game theoryMathNo attempts yet1s1024 MBJudgeable
Breaking BranchesTwo players alternately split pieces of a length n branch into integer parts; the last to move wins. Decide the winner and give Alice's winning first move.Medium4Game theoryMath+2No attempts yet1s512 MBJudgeable
Don't Split The Atom!Two players alternately split a pile of atoms, and whoever is forced to split a single atom loses; decide the winner for each n.Medium4Game theoryMath+2No attempts yet2s512 MBJudgeable
Substring Picking GamePlayers alternately subtract a value formed by a proper substring of the current number's digits, and you must find the smallest first move that forces a win, or -1 if none exists.Medium5Game theoryDynamic programming+2No attempts yet2s256 MBJudgeable
Number GameGiven a set of numbers including 1 and a limit K, find the first integer that cannot be formed using at most K chosen numbers, then decide the game winner by turn parity.Medium5Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Multiplication GameAlice and Bob multiply a running product by 2 to 9 in turn; find who forces the product to reach n first with optimal play.Medium5Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Cow Digit GameFor each starting number, players alternately subtract its largest or smallest nonzero digit, and the player who reaches 0 wins; decide if the first player wins.Medium5Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
NukitGiven counts of particles A, B, C, D, two players alternately remove one of five fixed multisets; find who wins under optimal play.Medium5Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
NimGiven a Nim position, count how many single-pile moves lead to a losing position (XOR of the remaining piles equals zero).Medium5Game theoryBit manipulation+1No attempts yet1s128 MBJudgeable
Stone Game 7Two players alternately remove a power of four stones from the pile, and the program reports the winner when both play perfectly.Medium5Game theoryMathNo attempts yet1s128 MBJudgeable
Filling a board with N-ominoes (Small)Given polyomino size X and board size R by C, decide whether the first player can choose a shape that makes the board impossible to tile.Medium5GeometryGame theory+1No attempts yet5s512 MBJudgeable
Winner of the Bubble GameTwo players alternately swap adjacent out-of-order pairs until the permutation is sorted; the one who cannot move loses. Decide the winner.Medium5CombinatoricsGame theory+1No attempts yet2s512 MBJudgeable
Root GameFor each N, decide who wins the subtraction game where a move subtracts any perfect square from a running total and taking the last square wins.Medium5Game theoryDynamic programming+2No attempts yet1s512 MBJudgeable
Nim Game 3Given Nim pile sizes, count how many first moves (choosing a pile and removing stones) leave the opponent in a losing position.Medium5Game theoryBit manipulation+2No attempts yet1s512 MBJudgeable
Multiplication GameDetermine, given a real number X and up to 6 multiplier cards at most 0.9, which player forces X below or equal to 1 first under optimal play.Medium6Game theoryMath+1No attempts yet2s128 MBJudgeable
Fibonacci GameDetermine the smallest first move in a Fibonacci-Nim-like bead-taking game that guarantees a forced win, or -1 if none exists.Medium6Game theoryNumber theory+1No attempts yet2s128 MBJudgeable
Math GameGiven N coins in a Fibonacci-like alternating take game, find the minimum first move Sangdeok can make to guarantee a win under optimal play.Medium6Game theoryMath+1No attempts yet1s128 MBJudgeable
Row and Column Deletion GameGiven an n x n matrix where players alternately remove the last row or column if its sum is even, determine which player wins with optimal play across possibly many test cases up to n=1000.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Two EndsFor each even-length row of cards, find the best score margin the first player can get when the second player always takes the larger end.Medium6Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
One Person “The Price is Right”Given G guesses and L lifelines, find the largest N such that a strategy guarantees a win for any price from 1 to N.Medium6Dynamic programmingGame theoryNo attempts yet1s128 MBJudgeable
Euclid's GameGiven two starting numbers, decide who wins the subtraction game Euclid's Game under optimal play, for each pair until the terminating 0 0 line.Medium6Game theoryMath+2No attempts yet1s128 MBJudgeable
Tobo or not ToboGiven a shuffled 3x3 Tobo board and a turn budget Y, find the minimum number of dial turns to restore the standard arrangement, or -1 if impossible within Y.Medium6BFSGame theory+1No attempts yet1s128 MBJudgeable
Odd, Even, and ChangyeongThree players move in fixed order, each adding 1 or dividing by a prime, and each tries to minimize the smallest number they personally produce.Medium6Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Drop the TriplesPlayers alternate drawing cards from a stock and may drop valid triples; each maximizes perfect triples then common triples. Report the winner or a tie.Medium6GreedyDynamic programming+2No attempts yet1s128 MBJudgeable
Treasure ChestTwo players alternately take a coin from either end of a row of N coins; find the maximum total the first player can guarantee with optimal play.Medium6Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Calendar GameOn a fixed 1900-2001 calendar, two players alternately advance a date by one day or to the same day next month; decide if the first player wins.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Infinite GameGiven sets A and B of positive steps taken alternately right and left, decide whether every integer can be reached.Medium6Number theoryDynamic programming+2No attempts yet5s128 MBJudgeable
Number GameWith Ellie's responses fixed by a1..a20, decide if the first player can force reaching 0 in a subtraction game.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
A Number GameA game on a blackboard starting from one number: split composites, subtract 1 from primes, take 1s for a point. Both play optimally; report final scores.Medium6Game theoryNumber theory+2No attempts yet1s128 MBJudgeable
PebblesPiles are sorted; a move reduces one pile without breaking the order. Determine whether the first player wins.Medium6Game theoryGreedy+1No attempts yet3s512 MBJudgeable
Paweł i GawełTwo players alternate moving a pawn across a grid, swapping floors whenever it enters a marked cell, each trying to hold the upper floor at the end.Medium6Game theoryDynamic programming+1No attempts yet3s128 MBJudgeable
GameTwo players alternately add to S within a range set by the current parity, and whoever first reaches F loses, so decide if the first player can force a win.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
ChompDecide whether each 3-row Chomp position is winning and output a move to a losing position.Medium6Game theoryDynamic programmingNo attempts yet1s128 MBJudgeable
Stone Game 8Count pile sizes up to M where the second player wins a take-away game with a fixed move set.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Pizza veto votingDecide whether your vetoes can keep your favorite pizza standing when Alice always vetoes the highest-calorie kind and Bob the lowest.Medium6GreedyGame theory+1No attempts yet3s256 MBJudgeable
Christmas WheatMirko raises one shortest stalk to the next height and Slavko lowers one tallest stalk until two distinct heights remain; report the winner and both extremes.Medium6SortingPrefix sum+2No attempts yet1s32 MBJudgeable
Coin Turning GameGiven a row of heads and tails, decide if the first player wins the interval-flip game and report the smallest winning first move.Medium6Game theoryDynamic programming+2No attempts yet2s256 MBJudgeable
Ultimate Tic-Tac-ToeGiven a partially played shrinking-board tic-tac-toe position, output the lexicographically smallest optimal next move under optimal play.Medium6Game theoryBrute force+1No attempts yet1s256 MBJudgeable
Card Game StrategyAlice picks t in [a, b] to maximize the gap while Bob replies with k cards whose sum is closest to t.Medium6Dynamic programmingGame theoryNo attempts yet5s1024 MBJudgeable
NimbleEach turn slides one coin left along numbered squares, so print which player moves the last coin onto square zero under optimal play.Medium6Game theoryBit manipulationNo attempts yet2s512 MBJudgeable
BrattleshipFind the fewest guesses that guarantee sinking a hidden 1 by W ship on an R by C board when an adversary relocates it to fit past answers.Medium6Game theoryGreedy+1No attempts yet5s512 MBJudgeable
Filling a Board with N-OminoesFor each case with piece size X and board R by C, decide whether Richard has an X-omino that blocks every tiling or Gabriel tiles the board anyway.Medium6Game theoryGeometry+1No attempts yet5s512 MBJudgeable
Last Hit (Small)Choose which monster to shoot or when to pass on each turn so your shots land the killing blow on the most valuable monsters before the tower kills them.Medium6Dynamic programmingGame theory+1No attempts yet5s512 MBJudgeable
Deceitful War (Small)Given both players' block weights, compute Naomi's best scores under honest War rules and under optimal lying in Deceitful War.Medium6GreedySorting+1No attempts yet5s512 MBJudgeable
Google Royale (Small)Compute the best possible chance of growing A dollars to V dollars with capped doubling bets and report the largest opening bet that reaches it.Medium6Dynamic programmingProbability+1No attempts yet10s512 MBJudgeable
King (Small)On a board of at most 16 squares with burned cells, a king moves to unvisited neighbors; decide who wins under optimal play.Medium6Game theoryDFS+1No attempts yet5s512 MBJudgeable
Stick GamePlace non-overlapping horizontal sticks of given lengths on a grid with obstacles; find the winner under optimal play.Medium6Game theoryImplementationNo attempts yet1s512 MBJudgeable
CardsGiven an even row of cards with integers, two players alternately take an end card; the first player maximizes his total sum while the second minimizes it. Report the best score the first player can guarantee.Medium6Dynamic programmingGame theory+2No attempts yet2s512 MBJudgeable
Kill the WerewolfFor each player assumed to be the werewolf, decide whether the villagers can outvote him; count the players who still win.Medium6GreedyImplementation+2No attempts yet2s512 MBJudgeable
MemoryGiven R times C face-down cards forming pairs, find the best-case and worst-case number of actions a perfect-memory player needs to clear the board.Medium6Game theoryMath+2No attempts yet1s256 MBJudgeable
MarblesTreat marbles as Wythoff/Nim heap coordinates and compute Sprague-Grundy values to decide if the first player wins.Medium6Game theoryMath+2No attempts yet2s512 MBJudgeable
Absolute GameAlice and Bob alternately delete elements from their own arrays until one element remains in each; Alice maximizes and Bob minimizes the final absolute difference.Medium6Game theoryGreedy+2No attempts yet1s256 MBJudgeable
Game of Nim EverywhereCount N in [L, R] where the Nim position (N, 2N, 3N) is a first-player win, i.e. where N xor 2N xor 3N is nonzero.Medium6Game theoryBit manipulation+2No attempts yet2s512 MBJudgeable
GameTwo players alternately claim columns they can reach; each wants to claim more columns than the other, and the winner under optimal play is reported.Medium6GreedyGame theory+2No attempts yet2s512 MBJudgeable
Number GameGiven a sequence of numbers, determine the winner of a two-player suffix-removal game where each player takes a suffix block ending at the current rightmost element and minimizes their own total sum, for three separate games with n up to 3000.Medium7Dynamic programmingGame theory+1No attempts yet2s128 MBJudgeable
VictoryCount first moves in a circular pick-up game with adjacency constraints that force a win for the first player against an optimal second player counting odd numbers picked.Medium7Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
BattleshipGiven two ship maps and a list of unlabeled shots, decide which admiral won under the hit-and-shoot-again turn rules.Medium7SimulationBrute force+2No attempts yet1s128 MBJudgeable
Parencedence!Two players alternately parenthesize one operator of an expression, maximizing and minimizing the value, and two rounds with swapped first movers decide the winner.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
The Thirty-One GameGiven a prefix of draws in the card game Thirty-One with cards 1 to 6, decide who wins from that position under perfect play with the remaining deck.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Hit or MissSimulate a multi-player solitaire card game and either report the last card each player discarded or declare the position unwinnable.Medium7SimulationQueue+2No attempts yet1s128 MBJudgeable
Find the Winning MoveGiven a 4x4 tic-tac-toe position with x to move, find the earliest cell in row-major order where x has a forced win, or report none.Medium7Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
Team DessertDesserts sit in a row; two alternating teams take from either end, and the first-picking team wants the smallest total weight it can guarantee against optimal play.Medium7Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Gold Coin GameGiven S coins and a legal move set of powers of K, find the smallest first move that guarantees a win for the starting player, or 0 if none exists.Medium7Game theoryMath+1No attempts yet1s128 MBJudgeable
Shuriken GameTwo players remove 1 to N shurikens from a pile, but a player cannot repeat the opponent's previous move; find the smallest winning first move.Medium7Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
Nim/3Three-player Nim where each player has a preferred winner; find player 1's optimal move with smallest stack then smallest count.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Joyful ColoringGiven subsets of size at most 3, decide whether every subset can be made non-monochromatic under a 2-coloring.Medium7BacktrackingGame theory+2No attempts yet3s128 MBJudgeable
Queen GameGiven N queens on an R by C board that move up, left, or up-left, decide if the first player wins with optimal play.Medium7Game theoryMath+1No attempts yet1s128 MBJudgeable
Cow CheckersFor each starting square on a large board, decide the winner of a two-player game with three kinds of leftward or downward moves.Medium7Game theoryMathNo attempts yet1s128 MBJudgeable
Number GameGiven the numbers still allowed by previous choices, list every move that leaves the opponent in a losing position, or report that none exists.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Number GameGiven the available numbers from 2 to 20 in a Number Game position, list every move that leaves the opponent in a losing position.Medium7Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
S-NimGiven a move set S, decide for each position whether the S-Nim game is a win or a loss by computing Grundy numbers and XORing them over the heaps.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
A Knightly PursuitGiven board size and starting squares for a pawn and a knight, decide whether the knight can win, force a stalemate, or loses, and report the minimum knight moves.Medium7BFSSimulation+2No attempts yet1s128 MBJudgeable
Snowball FightGiven fixed alternating throwing order and hit probabilities, players choose targets to maximize their team's win chance; compute win and draw probabilities under optimal play.Medium7Game theoryProbability+2No attempts yet1s128 MBJudgeable
VangOn a polygonal grid yard, a guard moving twice per turn chases a prisoner who can move or wait; report the guard turn when capture happens.Medium7BFSGraph+2No attempts yet1s1024 MBJudgeable
Game on ChessboardGiven K (p,q)-leapers on an M x N board, decide which player wins the disjunctive sum of impartial games.Medium7Game theoryMathNo attempts yet1s128 MBJudgeable
Fighting for TrianglesOn a triangular board with some edges already drawn, two players alternate adding edges, claiming a unit triangle when their edge completes it. Decide the winner with optimal play.Medium7Game theoryGraph+2No attempts yet2s512 MBJudgeable
Tree GameOn a tree, players alternately move a token to an unchosen neighbor from Manco's start vertex; find all start vertices where Manco wins with optimal play.Medium7TreeGame theory+2No attempts yet1s64 MBJudgeable
StripesGiven stripe lengths c, z, n, decide for each board length p whether the first player wins the impartial placement game.Medium7Game theoryDynamic programmingNo attempts yet3s512 MBJudgeable
MusketeersGiven a tournament matrix on n people in a circle, determine everyone who can be the last survivor when adjacent duels are scheduled in any order.Medium7Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Circular GameOn a circular board, white and black pieces slide over empty runs; decide with optimal play which side wins or whether play can go on forever.Medium7Game theoryArray+2No attempts yet1s128 MBJudgeable
ChocolateAn impartial chocolate-splitting game where eating the marked square loses. Count the squares whose marking makes the first player lose.Medium7Game theoryMath+1No attempts yet1s128 MBJudgeable