Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 950/E. Permutation of Rows and Columns
Prev
CodeforcesCodeforces
Expert
Codeforces Round 950

E. Permutation of Rows and Columns

MatrixGreedyHashing
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

You have been given a matrix π‘Ž of size π‘› by π‘š, containing a permutation of integers from 1 to π‘›β‹…π‘š.

A permutation of π‘› integers is an array containing all numbers from 1 to π‘› exactly once. For example, the arrays [1], [2,1,3], [5,4,3,2,1] are permutations, while the arrays [1,1], [100], [1,2,4,5] are not.

A matrix contains a permutation if, when all its elements are written out, the resulting array is a permutation. Matrices [[1,2],[3,4]], [[1]], [[1,5,3],[2,6,4]] contain permutations, while matrices [[2]], [[1,1],[2,2]], [[1,2],[100,200]]do not.

You can perform one of the following two actions in one operation:

  • choose columns π‘ and π‘‘ (1≀𝑐,π‘‘β‰€π‘š, π‘β‰ π‘‘) and swap these columns;
  • choose rows π‘ and π‘‘ (1≀𝑐,𝑑≀𝑛, π‘β‰ π‘‘) and swap these rows.

You can perform any number of operations.

You are given the original matrix π‘Ž and the matrix π‘. Your task is to determine whether it is possible to transform matrix π‘Ž into matrix π‘ using the given operations.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 950
Previous Problem