using System;
using System.Collections.Generic;
public class Program
{
public static void printPermutationRows(int[,] matrix, int givenrow) {
int rows = matrix.GetLength(0);
int cols = matrix.GetLength(1);
HashSet<int> Set = new HashSet<int>();
for (int j = 0; j < cols; j++) {
Set.Add(matrix[givenrow, j]);
}
for (int i = 0; i < rows; i++) {
if (i == givenrow) {
continue;
}
int j = 0;
for (; j < cols; j++) {
if (!Set.Contains(matrix[i, j])) {
break;
}
}
if (j != cols) {
continue;
}
Console.Write(i + ", ");
}
}
public static void Main(string[] args)
{
int givenrow = 1;
int[,] matrix = new int[,]
{
{7, 9, 4, 3, 1},
{4, 7, 9, 1, 3},
{4, 7, 8, 1, 2},
{1, 6, 9, 7, 4},
{9, 1, 3, 7, 4}
};
printPermutationRows(matrix, givenrow);
}
}
/*
run:
0, 4,
*/