UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeCompetitive ProgrammingMatrix Generator

Related Tools

Code FormatterComplexity CalcBit VisualizerBitmask PlannerPrime FactorsMEX CalcInterval MergerMatrix RotationPBDS GeneratorSegment TreeGraph VisualizerStress TesterModulo CalcConvex HullPath FinderOffline JudgeBig-O AnalyzerCombinatoricsDP Table BuilderExtended GCDSieve VisualizerBinary SearchSorting VisualizerSparse Table RMQUnion-Find DSU

I/O Matrix Generator

Generate grid/matrix inputs for competitive programming. Random, zeros, identity, or sequential fill. Outputs in multiple formats.

You Might Also Like

All Competitive Programming

Matrix Rotation

Input a 2D matrix, choose 90°/180°/270° CW or CCW rotation. See the visual index shift and get the C++ implementation.

Path Finder

Paint walls on an N×M grid, set start and end cells, then run BFS to visualize the shortest path. Copy the grid as a C++ 2D vector instantly.

Code Formatter

Format and beautify C++, Java, and Python code with consistent indentation. 100% client-side — no code leaves your browser.

Complexity Calc

Estimate Big-O operations and runtime for any N. Interactive reference table for all complexity classes from O(1) to O(N!).

Half of debugging a grid problem is having a grid to debug it with, and typing one out by hand is both slow and biased towards the cases you already thought of. The I/O Matrix Generator builds one to your dimensions, fills it four different ways, and prints it in the layout a judge expects.

The Prepend "N M" size line checkbox is the detail that saves the most time. Nearly every competitive problem reads the dimensions before the grid, so leaving it ticked means the block you paste is a complete stdin file rather than a body you still have to annotate.

Output appears twice: as a bordered table you can actually read, and as a monospace block ready to copy. Rows and columns are capped at 20 each and the values at plus or minus 1000, with typed values clamped rather than merely discouraged, because a 500 by 500 grid would lock the tab.

Getting a Test Grid Onto Your Clipboard

  1. Set Rows and Columns, then Min Val and Max Val for the random range. Entering them backwards is fine: the range is sorted before use, so 100 down to 1 behaves as 1 up to 100.
  2. Pick a Fill Mode. Random for a stress test, All Zeros for a blank canvas to edit, Identity for a matrix-multiplication sanity check, and Sequential when you need to see at a glance which cell is which.
  3. Choose an Output Format to match the problem statement rather than your preference.
  4. Press Generate Matrix. Nothing is produced until you do, and every press with Random selected gives a fresh grid, which is the point when you are hunting an intermittent failure.
  5. Check the table preview, then take the Copyable Output block below it.

Supported Formats for the Copyable Output

  • Space-separated (row) puts one row per line with single spaces between values, the near-universal convention on Codeforces and similar judges.
  • Comma-separated keeps the row structure but joins with commas, which is what you want when pasting into a C++ or Python array literal rather than into stdin.
  • One per line flattens each row into a vertical run, for problems that read a single value at a time and ignore line structure entirely.
  • Sequential numbers in row-major order starting from 1, so a 3 by 3 grid ends with 9 in the bottom-right corner and any transposition bug in your reader is immediately visible.
  • Identity marks a cell whenever the row index equals the column index, so on a non-square grid you get a partial diagonal instead of an error.
  • All Zeros ignores the min and max entirely, which makes it the fastest way to produce a blank grid of exact dimensions to edit by hand.
Configure your matrix above and click Generate Matrix