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 results333 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Hovering HornetExpected number of spots on a die visible from a random point in its box, counting a spot only when the segment to the viewer misses the die.Medium6GeometryProbability+1No attempts yet1s512 MBJudgeable
Rigged RouletteChoose integer bets within a budget on roulette numbers so the rigged wheel favors the least-bet numbers and expected profit is as large as possible.Medium6ProbabilityMath+1No attempts yet5s512 MBJudgeable
Falling Diamonds (Small)N diamonds fall onto a pile and slide left or right at random, and you compute the probability that one stops exactly at the given spot.Medium6ProbabilitySimulation+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
Dice Game Win ProbabilityA token moves on states 0 to N, stepping down with probability Q/P and up otherwise; find the probability of ending at N and print it modulo 1e9+7 as a reduced fraction.Medium6Dynamic programmingProbability+1No attempts yet1s512 MBJudgeable
RobotCompute the expected squared distance from the origin after a robot takes N probabilistic left, straight, or right moves, and print it as a fraction modulo 1e9+7.Medium6ProbabilityMath+1No attempts yet1s512 MBJudgeable
Rabbit MovementGiven a colored board of at most 17 cells, simulate rabbits that move, collide, and shrink the board, then compute the expected number left from a uniformly random start.Medium6SimulationCombinatorics+2No attempts yet2s512 MBJudgeable
Dice and CandiesFind the expected number of throws of a fair six-sided die until the running sum reaches at least N, and print the value to six decimals.Medium6Dynamic programmingProbability+2No attempts yet2s512 MBJudgeable
Torus SeaOn a torus of size N by M, a random walk moves diagonally each day; find the expected number of days to first reach (x, y), or -1 if unreachable.Medium6ProbabilityGraph+1No attempts yet2s512 MBJudgeable
Flipping CoinsEach step flips a uniformly random set of A_i coins; find the expected number of heads after all K steps.Medium6ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
Kangho's InvitationsGiven each friend's single disliked friend, find the expected number of friends who accept when a uniformly random invitation order is used.Medium6ProbabilityMath+1No attempts yet2s512 MBJudgeable
Lost in the WoodsGiven an undirected graph, find the expected number of random-walk steps from node 0 until node N-1 is reached.Medium6GraphProbability+2No attempts yet5s512 MBJudgeable
Lost in the NightOn a tree, a walker starting at node A repeatedly picks a uniformly random neighbor until reaching hotel B or C; find the probability of hitting B first.Medium6ProbabilityGraph+2No attempts yet2s512 MBJudgeable
Tournament WinsIn a random single elimination bracket of 2^k players, you are ranked r; find your expected number of wins.Medium6ProbabilityCombinatoricsNo attempts yet1s512 MBJudgeable
Electoral CollegeGiven each state's win probability and electoral votes, find the probability that Jenabkhan gets more than half of the total electoral votes.Medium6Dynamic programmingProbabilityNo attempts yet2s512 MBJudgeable
Dice BettingCompute the probability that at least k distinct values appear when an s-sided die is rolled n times, and print it to nine decimals.Medium6ProbabilityDynamic programming+2No attempts yet2s512 MBJudgeable
Vitcoin Lottery at Moloco (Easy)Order n tickets with prizes w_i and continuation probabilities p_i to maximize the expected sum of collected prizes, breaking ties by the lexicographically smallest permutation.Medium6GreedySorting+2No attempts yet2s512 MBJudgeable
Left-Right-WinFor players seated in a circle, compute how much of a $100 pot each should pay, given the spinner probabilities of moving left, moving right, or winning.Medium6ProbabilityMath+2No attempts yet2s512 MBJudgeable
Deceptive DiceGiven an n-sided die and at most k rolls, find the maximum expected final score when you may stop rolling at any point.Medium6Dynamic programmingProbability+2No attempts yet1s512 MBJudgeable
Pass the BuckGiven a graph where each holder moves to a random neighbor or wins with probability 1/(d+1), find the win probability of a target player from a given start.Medium6ProbabilityGraph+2No attempts yet1s512 MBJudgeable
Valentine's DayChoose a subset of n presents, each independently causing happiness with probability Pi, to maximize the probability that exactly one present causes happiness.Medium6ProbabilityGreedy+2No attempts yet2s512 MBJudgeable
RainsGiven a grid of regular N-gons with side S and a brain of radius R, find the probability a random brain center lands close enough to a thread to be cut.Medium6GeometryProbability+2No attempts yet2s512 MBJudgeable
Keys in BoxesGiven a uniformly random permutation of N keys among N locked boxes, find the exact probability that M bombs suffice to open every box, as a reduced fraction A/B.Medium7CombinatoricsProbability+2No attempts yet2s128 MBJudgeable
DartsCompute win probabilities up to score 501 for two darts players with different throw distributions, where B optimizes target section each turn.Medium7Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
So You Want to Be a 2ⁿ-aire?A contestant with a current prize faces n questions; each question's success chance p is uniform on [t,1]. Find the optimal expected prize, to three decimals.Medium7Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
PracticeGiven pairs (n, w), fit a logistic regression by maximizing the product of per-observation likelihoods and report the slope and intercept to four decimals.Medium7MathProbability+2No attempts yet1s128 MBJudgeable
Dumb BonesGiven the chance that each placed domino tips left or right, find the minimum expected total placements needed to finish a run of n dominoes.Medium7Dynamic programmingProbability+1No attempts yet1s128 MBJudgeable
Coin TossGiven a grid of m by n tiles of side t and a coin of diameter c, compute the percentage chance the coin covers exactly 1, 2, 3, or 4 tiles when its center lands uniformly at random in the rectangle.Medium7ProbabilityGeometry+2No attempts yet1s128 MBJudgeable
Fixing the BugsWith B bugs, T hours, and a failure factor f, choose each hour's bug by dynamic programming to maximize the expected total severity fixed.Medium7Dynamic programmingProbabilityNo attempts yet1s128 MBJudgeable
Random WalkingFor each graph, decide whether every bit position in every one of k random walk outputs has a 1-probability strictly between 25% and 75%.Medium7GraphProbability+2No attempts yet1s128 MBJudgeable
EvolutionGiven N DNA strings linked in an unknown parent-child order, compute each creature's probability of being the original ancestor.Medium7ProbabilityBit manipulation+1No attempts yet1s128 MBJudgeable
Random WalkParse a small random program with procedures and threshold IF/GOTO or PROC commands, then compute each requested procedure's expected running time to three decimals.Medium7ProbabilityGraph+2No attempts yet1s128 MBJudgeable
FamilyCompute the expected percentage of genes shared by pairs of monsters in a given family graph where each child inherits each gene from one parent at random.Medium7GraphDynamic programming+2No attempts yet1s128 MBJudgeable
Single-Player GamesGiven mutually recursive game-tree definitions, find each identifier's expected score under uniform random play, or report it undefined when the game may never end.Medium7ProbabilityMath+2No attempts yet1s128 MBJudgeable
Another LotteryEach of n players buys tickets across m rounds; round j pays 2^j to one random ticket. For each player, print the reduced fraction for the probability of winning strictly more money than everyone else.Medium7ProbabilityMath+2No attempts yet1s256 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
Collecting BugsFind the expected number of days until a stream of random (category, subsystem) pairs has covered all n categories and all s subsystems.Medium7Dynamic programmingProbability+2No attempts yet2s64 MBJudgeable
KeyFind every odd K in [A, B] such that (K-1)! is not a multiple of K^2, where B - A is at most 100 but B can be 10^18.Medium7Number theoryMath+2No attempts yet1s128 MBJudgeable
Bargain or No BargainGiven prize values and a budget M, decide whether optimal play maximizing expected log utility yields expected prize money above M.Medium7Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
Map GeneratorGiven N planets each edge appears independently with probability P, find the probability that the resulting random graph is connected.Medium7Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Map Generator Returns (MG-II)Given N places and independent edge probability P, find the probability that the random graph on N vertices is connected.Medium7ProbabilityDynamic programming+2No attempts yet1s128 MBJudgeable
The GoatCompute the expected area eaten when a goat is tied for k days to uniformly random stakes of length l, where overlaps depend on disk-pair geometry.Medium7ProbabilityGeometry+2No attempts yet1s128 MBJudgeable
DiceGiven n and k, find the number of ways n fair dice can sum to k, then output the integer part of 100 times that probability.Medium7Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
TournamentCompute the chance that two named entrants meet in a knockout bracket with random seeding and even match odds.Medium7ProbabilityTree+1No attempts yet1s128 MBJudgeable
Cellular NetworkYou sort n cells by their probabilities and split them into w ordered zones to minimize the expected number of paged cells.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Do Not Disturb!Two people wander a graph at random each step, and you must find the expected time until both reach node C at once.Medium7ProbabilityMatrix+1No attempts yet1s128 MBJudgeable
Goguryeo and the Crown PrinceGiven two different binary strings of equal length, compute the probability that the first appears before the second in fair coin flips.Medium7String matchingProbabilityNo attempts yet1s128 MBJudgeable
Probability ParadoxTwo players each pick a coin-flip pattern and the program computes the chance the first pattern appears before the second.Medium7ProbabilityString matching+1No attempts yet1s128 MBJudgeable
Join two kingdomsTwo trees with up to 40000 nodes each are joined by one uniformly random cross edge, and you must output the expected diameter of the combined tree.Medium7TreeSorting+2No attempts yet1s128 MBJudgeable
Bonus CardsDmitry compares his chance of winning a seat when he enters with a double-slot card and with a single-slot card.Medium7ProbabilityDynamic programming+1No attempts yet1s128 MBJudgeable
Card TrickGiven the cards on the observed hopping path, compute the chance that a random start among positions 1 to 10 ends on the same final card.Medium7Dynamic programmingProbability+1No attempts yet2s128 MBJudgeable
SuitcasesGiven n passengers, k belt suitcases with none yours, and misplacement chance p, compute the chance your suitcase missed the plane.Medium7ProbabilityMathNo attempts yet1s128 MBJudgeable
Slave to achievements 1Craft as many N-cost daggers as possible and reclaim 0-to-K chips per dagger until fewer than N remain then print each final remainder probability modulo 1e9+7.Medium7Dynamic programmingProbability+2No attempts yet3s256 MBJudgeable
Following FlowCompute the expected travel time from vertex 0 to vertex N when each step follows a uniformly random outgoing edge with its own crossing time.Medium7ProbabilityMatrix+1No attempts yet1s8 MBJudgeable
Bicycle picture puzzleThe program reads W, H, and S and prints the probability that a random scramble needs fewer optimal swaps than S.Medium7CombinatoricsProbability+2No attempts yet1s256 MBJudgeable
Typing monkeyGiven per-letter probabilities and two words P and Q, compute the probability that P appears as a substring before Q does.Medium7ProbabilityString matching+1No attempts yet1s256 MBJudgeable
Optimal ability loadoutChoose a subset of abilities with given trigger chances and damage values to maximize the expected damage of one attack under a random trigger order.Medium7Dynamic programmingProbabilityNo attempts yet1s512 MBJudgeable
RiskCompute the attacker win probability in a Risk battle with D-sided dice where the defender picks one or two dice after seeing the attack roll.Medium7Dynamic programmingProbability+2No attempts yet2s256 MBJudgeable
ARAM (Small)Decide when to spend a capped, regenerating reroll budget on fresh random champions to maximize the long-run share of games won.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Rigged RouletteSplit integer bets within budget B across 37 roulette numbers, where the ball lands on a least-backed number, to maximize expected payout minus cost.Medium7GreedySorting+2No attempts yet5s512 MBJudgeable
Observation WheelRandom arrivals fill the free gondolas of a circular wheel, and you compute the expected total of the distance-based fares.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
The Number TrickGiven K observed subset products, find the most likely hidden multiset of N numbers from 2 to M under the given posterior score.Medium7Brute forceCombinatorics+1No attempts yet5s1536 MBJudgeable
Perfect GameFind the level order that minimizes the expected time to clear every level in one deathless run when any death restarts the run from the first level.Medium7GreedyProbability+1No attempts yet5s512 MBJudgeable
Perfect GameOrder the levels to minimize the expected total play time when any death restarts the run from the first level.Medium7GreedySorting+1No attempts yet5s512 MBJudgeable
Breaking Windows (Small)M workers randomly reinforce K windows and N villains randomly throw one stone each, and the task asks for the probability that at least one window breaks.Medium7ProbabilityCombinatorics+1No attempts yet5s512 MBJudgeable
Breaking Windows (Large)Compute the chance that random stone throws break at least one of K windows after random reinforcements raise their durability.Medium7ProbabilityCombinatorics+1No attempts yet30s512 MBJudgeable
Market Board (Large)Free dice land on uniform random faces and each cell scores by the longest run of two to four equal faces covering it; find the expected total.Medium7ProbabilityCombinatoricsNo attempts yet5s512 MBJudgeable
Champion Sort (Large)Find the minimum expected number of uniform shuffles of adaptively chosen positions needed to sort a permutation of 1 to N.Medium7ProbabilityCombinatorics+1No attempts yet5s512 MBJudgeable
Year of More Code Jam (Small)Given T tournaments with fixed round offsets and N equally likely start days, compute the exact expected value of the sum of squared daily round counts.Medium7MathProbability+1No attempts yet5s512 MBJudgeable
A Year of More ContestsGiven T tournaments with fixed round offsets, each starting on a uniformly random day among N, compute the exact expected sum of squared daily round counts.Medium7ProbabilityMath+1No attempts yet5s512 MBJudgeable
Collecting CardsEach pack is a uniformly random N-subset of C card kinds; find the expected number of packs until all C kinds are collected.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Collecting Every CardFind the expected number of booster packs to buy, each pack giving N distinct kinds, until all C kinds are collected.Medium7ProbabilityDynamic programming+2No attempts yet5s512 MBJudgeable
Test Passing Probability (Small)With M submissions and Q questions of 4 choices each, find the maximum probability of answering every question correctly, learning only whether each submission passed.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
FunfairPick and order k games from n so the expected final money is maximized, then report that value.Medium7Dynamic programmingSorting+1No attempts yet2s512 MBJudgeable
SpeedrunGiven per-road win probabilities, choose checkpoints to save at so the expected time to reach checkpoint n is minimized.Medium7ProbabilityDynamic programmingNo attempts yet8s512 MBJudgeable
Rock Paper Scissors RankingGiven each contestant's probabilities for scissors, rock, and paper, find the probability that contestant 1 finishes in place K of the recursive elimination tournament.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
AbilityCompute the expected damage of one attack where abilities are tried in a uniformly random order without replacement until one fires, and output the fraction modulo 1e9+7.Medium7ProbabilityMath+2No attempts yet2s512 MBJudgeable
BitsGiven N bits and K odd random index toggles per operation after sorting, compute for each starting zero count the expected number of operations to reach all ones.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
CardsFind the probability that L random packs of N equally likely card types meet every demand D_i, output as a fraction mod 1e9+7.Medium7Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Holiday RoadsOn a tree, each of M families picks one of the other N-1 cities uniformly and independently; find the expected number of roads used by every family.Medium7TreeProbability+1No attempts yet2s512 MBJudgeable
Lottery interestCompute Kangho's expected balance after C weekly lottery drawings, where each ticket (one per won) is equally likely to win J, and print the exact fraction.Medium7ProbabilityMath+1No attempts yet2s512 MBJudgeable
Arcade!Given a triangular grid of holes with per-hole bounce probabilities and payouts, compute the expected payout of one dropped ball.Medium7ProbabilityDynamic programming+2No attempts yet2s512 MBJudgeable
Random Sort 2Compute the expected number of random swaps the process needs to turn a given permutation of size up to 10 into increasing order.Medium7ProbabilityDynamic programming+2No attempts yet2s512 MBJudgeable
The ResistanceGiven past mission teams and sabotage counts, choose Q players most likely to contain no spy and print that probability.Medium7ProbabilityCombinatorics+1No attempts yet2s512 MBJudgeable
Just in TimeGiven N rooms where each room has one random outgoing tunnel, choose T in [2, N] maximizing the chance a walker starting in room 1 is not back in room 1 at time T.Medium7ProbabilityMath+2No attempts yet2s512 MBJudgeable
Dinner BetGiven N balls, D drawn per round, and two size-C cards, find the expected number of rounds until one player completes their card.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
Foreign PostcardsPlace postcards in random batches, flipping a batch when its top card is upside down, and compute the expected number left picture down.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
ProbabilityGiven probabilities of letters A to D, find the probability that an optimally played game fills a row of n cells in alphabetical order.Medium7Dynamic programmingProbability+2No attempts yet1.5s512 MBJudgeable
SegmentsGiven N vertical segments at increasing x, pick A on segment 1 and B on segment N uniformly; find the probability that chord AB crosses every segment.Medium7GeometryProbability+1No attempts yet0.5s256 MBJudgeable
Two BallsTwo balls move on a grid for T seconds with different random rules; compute the probability they collide, to 4 decimals.Medium7ProbabilityDynamic programming+1No attempts yet1s256 MBJudgeable
ProficiencyGiven two counters with geometric service times, find the probability that all L1 people finish before all L2 people do.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
Family Hotel (Large)Rooms fill by repeatedly picking a random adjacent free pair until none remain; find the probability that a given room ends up occupied, modulo 1e9+7.Medium7ProbabilityMath+2No attempts yet5s512 MBJudgeable
Red Tape Committee (Large)Choose exactly K of N members, each with a known Yes probability, to maximize the chance that exactly half vote Yes.Medium7Dynamic programmingProbability+2No attempts yet5s512 MBJudgeable
Card CollectingCompute the minimum expected time to collect all n cards, choosing when to trade d cards for a chosen card or play for a random pack.Medium7Dynamic programmingProbability+1No attempts yet2s512 MBJudgeable
Coin tossingGiven head counts from tossing two coins whose head probabilities are independent uniform on [0,1], compute the probability that the first coin's probability is smaller.Medium7ProbabilityMath+2No attempts yet2s512 MBJudgeable
Flipping CoinsGiven N coins all tails and exactly K fair tosses chosen adaptively, find the maximum expected number of heads at the end.Medium7ProbabilityDynamic programming+1No attempts yet4s512 MBJudgeable
Cactus graph edge removalDelete uniformly random edges one at a time from a cactus graph until it disconnects, and output the expected number of deletions to six decimals.Medium7ProbabilityGraph+2No attempts yet1s512 MBJudgeable
KDH, Son of the TyphoonOn a tree where every pair of vertices adds 1 traffic to each path edge, vertices survive independently with probability p; find the expected total traffic.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
LoL TournamentGiven a tournament bracket where each winner is renumbered, find which starting positions give the highest chance of winning all n-1 rounds with per-round win probability p.Medium7GraphTree+2No attempts yet5s512 MBJudgeable
Lottery for Vitcoins at Moloco (Hard)Order the tickets to maximize the expected sum of prizes, where ticket i stops the lottery with probability 1 - p_i, and break ties by the lexicographically smallest permutation.Medium7GreedySorting+2No attempts yet2s512 MBJudgeable