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 results123 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
The Worm TurnsSimulate a 20-cell worm on a 50x50 grid through a list of moves, stopping when it hits itself, leaves the board, or finishes.Easy2SimulationImplementation+2No attempts yet1s128 MBJudgeable
Van Gogh's Work ScheduleSimulate a first-come queue of painting jobs and print arrivals, starts, and finishes for hours 0 to 23.Easy2SimulationQueueNo attempts yet1s64 MBJudgeable
Josephus PermutationSimulate the Josephus elimination order for N people counting off every K-th person in a circle and print the removal sequence.Easy3QueueSimulation+1No attempts yet2s256 MBJudgeable
Printer QueueSimulate a queue where documents are printed only when no higher-priority document remains, and find the print order of a specific document.Easy3QueueSimulationNo attempts yet2s128 MBJudgeable
Card 1Simulate a queue where you discard the front card then rotate the next card to the back, printing the discard order and final survivor.Easy3QueueSimulationNo attempts yet2s128 MBJudgeable
Card 2Simulate the Josephus-style card elimination process to find which card number remains last for a given N.Easy3QueueSimulation+1No attempts yet2s128 MBJudgeable
Hotel Room AssignmentSimulate assigning arriving groups to hotel rooms with two beds each, filling empty rooms first then pairing singles, and output the final occupancy per room.Easy3SimulationQueue+1No attempts yet1s128 MBJudgeable
And Then There Was OneSimulate a Josephus-style circle elimination game with a custom starting removal point and report the last remaining stone for each test case.Easy3SimulationQueue+1No attempts yet1s128 MBJudgeable
Ferry Loading IVSimulate a ferry of given length that repeatedly crosses between two banks, loading waiting cars in arrival order.Easy3SimulationQueueNo attempts yet1s128 MBJudgeable
CardsApply k top-to-bottom card moves in order and report the number on top of the deck.Easy3QueueSimulationNo attempts yet1s128 MBJudgeable
Snake game simulationSimulate 20 snake moves on a 15 by 15 board with growth on pellets and print the pellet count or game over with the final board.Easy3SimulationQueueNo attempts yet1s256 MBJudgeable
QueueProcess a sequence of push, pop, size, empty, front, and back commands on an integer queue and print each result.Easy3QueueNo attempts yet0.5s256 MBJudgeable
DequeProcess up to 10000 push, pop, size, empty, front and back commands on an integer deque and print each query result.Easy3QueueImplementationNo attempts yet0.5s256 MBJudgeable
Waiting for ChangeSimulate book sales across two queues with limited five-dollar change and report line B at its longest moment.Easy3SimulationQueueNo attempts yet1s256 MBJudgeable
Josephus PermutationRemove every Kth person from a circle of N people and print the removal order in angle brackets.Easy3QueueSimulationNo attempts yet2s512 MBJudgeable
Theme Park (Small)Groups board a k-seat coaster in queue order and rejoin the back after each run, so simulate R runs and add one euro per rider.Easy3SimulationQueueNo attempts yet5s512 MBJudgeable
Theme Park (Small)Groups board a k-seat coaster in queue order without skipping, riders rejoin the back, and total earnings over R runs are computed.Easy3SimulationQueueNo attempts yet5s512 MBJudgeable
Ping Pong Balls (Small)Given two fixed displacement vectors, simulate the chain reaction from one starting trap and count how many distinct traps fire.Easy3SimulationBFS+2No attempts yet5s512 MBJudgeable
TrucksTrucks cross a one-lane bridge in order under a weight limit; find the earliest time all have finished.Easy3QueueSimulationNo attempts yet1s512 MBJudgeable
Course registrationGiven a click log of student numbers and K seats, keep each student's last click, then print the first K distinct students in that order.Easy3QueueHash map+1No attempts yet1s256 MBJudgeable
RouterSimulate a buffer of size N: packets arrive in order, 0 means one is handled and removed from the front, and a packet arriving with the buffer full is dropped.Easy3QueueSimulation+2No attempts yet1s512 MBJudgeable
Queue 2Implement a queue supporting push, pop, size, empty, front, and back, and run N commands, printing output for the query commands.Easy3QueueImplementation+2No attempts yet1s512 MBJudgeable
Josephus Permutation 2Given N people in a circle and a step size K, output the full removal order produced by repeatedly eliminating every K-th remaining person.Medium4QueueSimulation+1No attempts yet0.15s128 MBJudgeable
Card MagicFind an initial card order so that repeatedly cycling and dealing cards produces the sequence 1 to N on the table.Medium4SimulationQueue+1No attempts yet2s128 MBJudgeable
Popping BalloonsSimulate popping balloons arranged in a circle, moving left or right by the value on each popped balloon among remaining balloons.Medium4SimulationLinked list+1No attempts yet2s4 MBJudgeable
Finding Silent IntervalsFind every starting index of a length-m window in an array where the max minus min value is at most c, using a sliding window with monotonic deques.Medium4Sliding windowQueue+1No attempts yet1s128 MBJudgeable
SnakeSimulate a classic snake moving on an N x N grid with given apple positions and scheduled turn events, and output the second when it hits a wall or itself.Medium4SimulationQueue+1No attempts yet1s128 MBJudgeable
Card Pickup GameSimulate removing cards 1..N in order from a circular scan of a row, counting how many times the search wraps past the right end.Medium4QueueSimulation+1No attempts yet1s128 MBJudgeable
Indiana Jones and the Lost Soccer CupGiven precedence constraints between levers, decide whether the order is unique; print the unique order, or report no order or multiple orders.Medium4Topological sortGraph+2No attempts yet1s256 MBJudgeable
JugglefestSimulate the first 20 throws of a siteswap pattern, assigning balls in order of first use, and detect any time two balls are due on the same throw.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
Parking LotSimulate cars arriving and leaving a parking lot, assigning each to the lowest-numbered free space or a waiting queue, and sum weight times rate.Medium4SimulationQueue+2No attempts yet1s128 MBJudgeable
Hide and SeekIn a connected undirected graph, find the barn farthest from barn 1. Print the smallest such barn number, its distance, and how many barns tie at that distance.Medium4GraphBFS+2No attempts yet1s256 MBJudgeable
Cow LineMaintain a deque of cows under left/right insertions and left/right bulk removals, then print the remaining cows left to right.Medium4QueueLinked list+2No attempts yet1s128 MBJudgeable
Card StackingSimulate a deck where each dealt card is followed by moving P cards to the bottom, and report the original positions that reach Bessie.Medium4SimulationQueue+2No attempts yet1s128 MBJudgeable
M*A*S*HSimulate a card-driven counting-out lottery on a line of P people until X survivors remain, then print their original positions in increasing order.Medium4SimulationArray+2No attempts yet1s128 MBJudgeable
Bridge CrossingSplit a line of people into consecutive groups of at most M, where each group costs its slowest member's time, and minimize the total cost.Medium4Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
The Mysterious X NetworkGiven an undirected graph of N people, find the minimum number of intermediate people on a shortest path between two given people.Medium4GraphBFS+2No attempts yet1s128 MBJudgeable
TomatoesGiven a grid of ripe, unripe, and empty cells, find how many days until every tomato ripens or report -1 if some never can.Medium4BFSGraph+2No attempts yet1s256 MBJudgeable
SSSP (Shortest Path Queries)Run the given SPFA shortest-path algorithm for each query and also output a push counter that accumulates across all queries.Medium4Shortest pathGraph+2No attempts yet1s128 MBJudgeable
PilotsFind the length of the longest contiguous fragment whose maximum minus minimum is at most t.Medium4Sliding windowTwo pointers+1No attempts yet3s128 MBJudgeable
SnakeSimulate the snake's moves on the board and report the move on which its head hits a wall or its own body.Medium4SimulationQueue+1No attempts yet1s512 MBJudgeable
Card ShufflingGiven a deck numbered from the top and a string of two shuffle moves, find the three cards at positions k-1, k and k+1 after all moves.Medium4SimulationQueueNo attempts yet2s512 MBJudgeable
Exploration TeamFind the size of the largest group where every member has at least k friends inside the group.Medium4GraphQueueNo attempts yet1s256 MBJudgeable
Sliding Window MinimumPrint the minimum of each window of length L ending at every position of the array.Medium4Sliding windowQueueNo attempts yet2.4s512 MBJudgeable
Miraculous DrugEach hour uses the cheapest enzyme bought within the last h hours, breaking ties toward the latest hour, and reports purchase counts over a given interval.Medium4Sliding windowQueueNo attempts yet1s256 MBJudgeable
gSnake (Small)Simulate a growing snake that eats food on alternating cells of a wrapping board with scheduled turns and report its length when it collides or time runs out.Medium4SimulationQueueNo attempts yet5s512 MBJudgeable
Mousetrap (Small)For each query index, report which card occupies that position in the unique deck that removes cards in order 1..K.Medium4QueueSimulation+1No attempts yet30s512 MBJudgeable
Jump JumpGiven jump distances on a row of n stones, count how many stones are reachable from a starting stone via left or right jumps that stay on the bridge.Medium4GraphBFS+2No attempts yet2s512 MBJudgeable
Eenie Meenie Miney MoeSimulate elimination in a circle of N heifers using a repeating sequence of up to L step sizes, and report the last heifer left.Medium4SimulationImplementation+1No attempts yet2s512 MBJudgeable
Olympiad PizzaContestants queue for pizza slices; each takes one slice per turn and rejoins the back if still hungry. Report the second each finishes.Medium4QueueSimulation+2No attempts yet2s512 MBJudgeable
Eeny MeenySimulate counting around a circle of kids with a rhyme length, removing one kid per round and assigning them to alternating teams.Medium4SimulationImplementation+2No attempts yet2s512 MBJudgeable
Run, HongjunGiven N billboard intensities and a sight range M, output the maximum intensity within a sliding window of size 2M-1 for each valid position.Medium5Sliding windowQueue+1No attempts yet2s256 MBJudgeable
Candidate RecommendationSimulate N photo frames where each recommendation either updates a displayed student's count or evicts the least-recommended, longest-displayed student to show the new one.Medium5SimulationHash map+2No attempts yet2s128 MBJudgeable
AirplaneSimulate passengers walking down a single aisle to their assigned row and taking 5 seconds to load luggage, blocked by others ahead, to find total boarding time.Medium5SimulationQueue+1No attempts yet1s128 MBJudgeable
Stock PricesSimulate an order book with buy and sell orders, matching bids and asks at the ask price, and report ask, bid, and last trade price after each order.Medium5SimulationImplementation+1No attempts yet1s128 MBJudgeable
Chat RoomsFor each submitted line, decide accept or reject using consonant-run length, the count of recent suspicious lines, and recent duplicate counts over a sliding window of the last 10 lines.Medium5Sliding windowString+2No attempts yet1s128 MBJudgeable
SnapSimulate the two-player Snap card game with card flipping, pile recycling, and a fixed random tie-breaker for up to 1000 turns.Medium5SimulationQueue+1No attempts yet1s128 MBJudgeable
Dueling PhilosophersGiven m precedence edges among n essays, decide whether the es-says have zero, exactly one, or more than one valid topological ordering.Medium5GraphTopological sort+2No attempts yet2s128 MBJudgeable
ASM – The Abelian Sandpile ModelDrop grains one at a time on a grid and repeatedly topple any cell over the critical height, losing grains that fall off the edge, until the pile is stable.Medium5SimulationQueue+2No attempts yet1s128 MBJudgeable
Bora BoraSimulate a children's card game with turn order, direction changes, forced draws and skips, and a fixed discard rule, and report the winner.Medium5SimulationImplementation+2No attempts yet1s128 MBJudgeable
Relay RaceEach cow runs one lap, then signals other cows to start; find the time when the last cow finishes, ignoring repeat signals.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Team QueueSimulate a team queue where each new element cuts in behind its own teammates, if any, and otherwise joins the tail; print every dequeued element.Medium5QueueHash map+2No attempts yet1s128 MBJudgeable
Barking Dogs!Given dogs with wake-up delays and a directed hearing graph, simulate who barks each second from 0 to T and count each dog's barks.Medium5SimulationGraph+2No attempts yet2s512 MBJudgeable
Chemical ReactionsCount unowned compounds that become producible by repeatedly firing reactions whose substrates are all available.Medium5BFSGraph+1No attempts yet1s512 MBJudgeable
Neighborhood RivalryEach cell of the grid needs the maximum value inside the square of radius R centered on it.Medium5Sliding windowMatrix+1No attempts yet2.5s128 MBJudgeable
Crowded CowsCount cows that have a cow at least twice as tall within distance D on both the left and the right.Medium5Sliding windowSorting+1No attempts yet1s128 MBJudgeable
2D Max FilterFor every cell of an R by C grid, output the maximum value inside the rectangular window centered on that cell, clipped at the borders.Medium5Sliding windowQueue+1No attempts yet1s128 MBJudgeable
Hyper-minimumCompute the minimum of every M by M by M by M subcube of a 4D array with up to 1.5 million entries.Medium5Sliding windowQueueNo attempts yet2s256 MBJudgeable
PairingGiven complete preference rankings of N men and N women, compute the man-optimal stable pairing.Medium5GreedySimulation+1No attempts yet3s128 MBJudgeable
Sum of submatrix maximaAdd up the maximum value inside every K by K submatrix of an N by N matrix generated from two arrays.Medium5Sliding windowMatrix+1No attempts yet20s1024 MBJudgeable
Theme Park (Large)Groups board a coaster holding at most k people in queue order and rejoin the back after riding, and R runs of earnings must be totaled.Medium5SimulationQueue+1No attempts yet5s512 MBJudgeable
Theme Park Roller CoasterSimulate R rides where groups at the front board until the next group cannot fit, then return to the back; report total earnings.Medium5QueueSimulation+1No attempts yet5s512 MBJudgeable
SouvenirParticipants sit in a circle; stage t removes the t^3-th person counting clockwise from the current host, and you find the last survivor.Medium5SimulationQueue+2No attempts yet2s512 MBJudgeable
Trading Union DeparturesStarting from country L leaving, each country exits once at least half its original partners have left; decide whether X exits too.Medium5GraphSimulation+1No attempts yet2s512 MBJudgeable
Jupiter OrbiterGiven queues with capacities, sensor writes between downlink windows, and per-window downlink limits, decide whether every queue can be emptied.Medium5SimulationQueue+1No attempts yet2s512 MBJudgeable
Foosball DynastySimulate a foosball variation where seats rotate after each point and report the team whose scoring streak lasted longest.Medium5SimulationImplementation+2No attempts yet2s512 MBJudgeable
Miss That Bus and You Are Late!!Simulate a single-lane bus stop where each bus parks in the frontmost free spot, waits if a bus ahead is still parked, and departs after its dwell time; report the parking spot of the m-th bus.Medium5SimulationQueue+1No attempts yet1s512 MBJudgeable
Passport ControlDecide whether a given exit permutation can arise from a FIFO arrival line feeding k desk queues, each holding an arrival-ordered subsequence.Medium5QueueStack+2No attempts yet0.2s512 MBJudgeable
Drug Investigation UnitGiven a directed supply graph and a set of arrested suppliers, count how many remaining suppliers still receive drugs from some origin.Medium5GraphDFS+2No attempts yet1s256 MBJudgeable
Musical ChairsSimulate the Josephus elimination where each eliminated person's own number k sets the next count length, and print the last survivor.Medium5SimulationQueue+2No attempts yet1s512 MBJudgeable
Teleport StationGiven N points in a line, edges between x-1 and x+1, plus M teleport connections, find the shortest time from S to E.Medium5GraphBFS+2No attempts yet2s512 MBJudgeable
BNKQCustomers arrive over time and each joins the shortest counter queue; find the total time until the last customer finishes being served.Medium5SimulationHeap+2No attempts yet2s512 MBJudgeable
Queuing at the DoctorsSimulate visitors moving through a sequence of doctor offices, forming queues by arrival order and number, to find when the last person leaves.Medium6SimulationQueue+2No attempts yet1s128 MBJudgeable
FerrySimulate a shuttling ferry with capacity M and crossing time t, picking up waiting passengers with priority for those who arrived earlier, and output each passenger's arrival time on the opposite bank.Medium6SimulationQueue+1No attempts yet2s128 MBJudgeable
ExchangeImplement a limit order book that matches buy/sell orders FIFO by price-time priority, supports cancellation, and emits trades and quotes for each message.Medium6QueueSimulation+1No attempts yet1s128 MBJudgeable
Book ReplacementSimulate a library queue where a librarian relocates books between capacity-limited desks and a shelf using an LRU-like eviction rule, and compute total access cost.Medium6SimulationQueue+1No attempts yet1s128 MBJudgeable
Fire!Given a grid with walls, one starting cell, and fire cells that spread each second, find the earliest time the person can step off the map.Medium6BFSGraph+2No attempts yet1s256 MBJudgeable
Mowing the LawnGiven N cows in a row with efficiencies, pick a subset that never includes more than K adjacent cows and maximize the total efficiency.Medium6Dynamic programmingSliding window+2No attempts yet1s128 MBJudgeable
Parallel Computer SimulatorSimulate up to ten concurrent programs on one CPU with FIFO scheduling, quantum preemption, and lock/unlock mutual exclusion, then report prints in execution order.Medium6SimulationQueue+2No attempts yet1s128 MBJudgeable
Sorting It All OutGiven up to n letter ordering constraints added one at a time, report the first point where a unique sorted order emerges or where the constraints contradict each other.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
EurozwrotnicaDecide whether the arriving train order can be split across two FIFO tracks so all trains leave in increasing order.Medium6QueueGreedyNo attempts yet2.5s128 MBJudgeable
People like peopleFrom each voter list of up to three liked students, find the largest group where everyone voted, likes only members, and is liked by a member.Medium6GraphQueue+1No attempts yet1s128 MBJudgeable
Binary GameRead two binary strings and decide whether the first can reach the second by deleting the front character or appending the current parity bit.Medium6QueueMathNo attempts yet1s256 MBJudgeable
Professor Normal's Marble GameChildren on a grid repeatedly drop out when short on marbles, then survivors pass 12 marbles to neighbors; count the exchanges or the children who play forever.Medium6SimulationQueue+1No attempts yet5s512 MBJudgeable
Suspicious SamplesFor each condition, count samples whose value is greater or less than the min, max, or average of samples in the preceding time window.Medium6Sliding windowQueue+2No attempts yet2s512 MBJudgeable
Dueling PhilosophersGiven directed edges meaning essay d must precede essay u, decide whether the ordering is impossible, unique, or has multiple solutions.Medium6GraphTopological sort+2No attempts yet2s512 MBJudgeable
Baby SharkOn a grid with fish and a baby shark that eats smaller fish and grows, simulate its BFS-driven meal choices and report the total time spent.Medium6BFSGraph+2No attempts yet2s512 MBJudgeable
Seoul Subway Line 2Given a connected graph with N vertices and N edges (exactly one cycle), find each vertex's distance to the unique cycle.Medium6GraphBFS+2No attempts yet2s512 MBJudgeable
Restroom RulesEmployees are dealt into M lines round-robin; repeatedly the head with the largest D, then largest H, then smallest line index is served. Count who goes before Deka.Medium6SimulationHeap+2No attempts yet1s1024 MBJudgeable
PicnicGiven N students in a circle removing every K-th person Josephus-style, find the round number in which a specific student M is eliminated, with N and K up to 5,000,000.Medium7Segment treeSimulation+2No attempts yet1s128 MBJudgeable