Arka fon
Her yarışmacının diğer yarışmacılara karşı bir oyun oynadığı yuvarlak robin turnuvasını düşünün. Beraberlik yok, bu yüzden her oyunda bir kazanan ve kaybeden var. Bir yarışmacı A bir olan kral her yarışmacı için ise, turnuvanın B ya A yendi B veya A başka yarışmacı yendi C sırayla yendi B . Her turnuvanın en az bir kralı olduğu gösterilebilir (ancak birkaç tane olabilir). Bu mücadelede, göreviniz verilen bir turnuvanın krallarını bulmaktır.
Giriş ve çıkış
N × N
Girişiniz bir boole matrisi T
ve isteğe bağlı N ≥ 2
olarak yarışmacı sayısıdır . Her giriş T[i][j]
rakip arasından oyunun sonucunu temsil etmektedir i
ve j
değeri 1 için kazanmak temsil eder, i
bir kazanmak ve 0 j
. Dikkat T[i][j] == 1-T[j][i]
edin i != j
. Diyagonal T
0'lardan oluşur.
Çıktınız, T
0 veya 1 tabanlı indeksleme kullanarak turnuvadaki kralların listesi olacaktır . Kralların sırası ilgisizdir, ancak kopyalar olmamalıdır.
Hem giriş hem de çıkış makul bir formatta alınabilir.
Kurallar ve puanlama
Tam bir program veya işlev yazabilirsiniz. En düşük bayt sayısı kazanır ve standart boşluklara izin verilmez.
Test senaryoları
Bu test senaryoları 0 tabanlı indeksleme kullanır. 1 tabanlı indeksleme için, her çıkış değerini artırın.
2 [[0,0],[1,0]] -> [1]
3 [[0,1,0],[0,0,0],[1,1,0]] -> [2]
3 [[0,1,0],[0,0,1],[1,0,0]] -> [0,1,2]
4 [[0,1,1,1],[0,0,1,0],[0,0,0,0],[0,1,1,0]] -> [0]
4 [[0,1,1,0],[0,0,1,0],[0,0,0,1],[1,1,0,0]] -> [0,2,3]
5 [[0,1,0,0,1],[0,0,0,0,1],[1,1,0,0,0],[1,1,1,0,1],[0,0,1,0,0]] -> [3]
5 [[0,1,0,1,0],[0,0,1,1,1],[1,0,0,0,0],[0,0,1,0,1],[1,0,1,0,0]] -> [0,1,4]
5 [[0,0,0,0,0],[1,0,1,1,0],[1,0,0,0,1],[1,0,1,0,1],[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