# 谁是比赛的王者？

13

## 测试用例

`````` 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],[1,1,0,0,0]] -> [1,3,4]
6 [[0,0,0,0,0,0],[1,0,1,1,0,0],[1,0,0,1,1,0],[1,0,0,0,1,1],[1,1,0,0,0,1],[1,1,1,0,0,0]] -> [1,2,3,4,5]
6 [[0,0,1,1,1,0],[1,0,0,1,1,1],[0,1,0,0,1,0],[0,0,1,0,0,1],[0,0,0,1,0,1],[1,0,1,0,0,0]] -> [0,1,2,3,5]
6 [[0,1,1,0,0,1],[0,0,0,1,0,1],[0,1,0,1,1,0],[1,0,0,0,1,1],[1,1,0,0,0,0],[0,0,1,0,1,0]] -> [0,1,2,3,4,5]
8 [[0,0,1,1,0,1,1,1],[1,0,1,0,1,1,0,0],[0,0,0,1,1,0,0,0],[0,1,0,0,0,1,0,0],[1,0,0,1,0,1,0,0],[0,0,1,0,0,0,1,0],[0,1,1,1,1,0,0,1],[0,1,1,1,1,1,0,0]] -> [0,1,4,6,7]
20 [[0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,1,0,1],[1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1],[0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,1],[0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1],[1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1],[0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1],[0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0],[1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,1,0],[1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1],[1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,1,1,1],[1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0],[0,1,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1],[0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,1],[1,0,1,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1],[0,0,1,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1],[0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1],[0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1],[0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1],[1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0]] -> [0,1,3,4,5,7,8,11,15,17,18]
``````

（是否存在运行时间或内存限制？）没关系。我完全误解了规格。

@丹尼斯·诺普 只要您的程序在理论上可以在无限制的时间和内存的情况下运行，就可以了。
Zgarb

edc65

@ edc65这是一个很好的观察。我将其编辑成挑战。
Zgarb

9

# Matlab，36 35 29字节

``````@(T,N)find(sum(T*T>-T,2)>N-2)
``````

（这是MATLAB，因此索引基于1。）

MATLAB矩阵应使用分号作为行定界符进行编码：

``````[[0,0,0,0,0];[1,0,1,1,0];[1,0,0,0,1];[1,0,1,0,1];[1,1,0,0,0]]
``````

Luis Mendo

7

# Jelly，13 12 11个字节

``````a"€¹o/€oḅ1M
``````

``````×Ḅ|/€|ḄBS€M
``````

### 怎么运行的

``````a"€¹o/€oḅ1M  Main link. Argument: M (matrix)

¹         Yield M.
€          For each row of M:
a"           Take the logical AND of each entry of that row and the corr. row of M.
o/€      Reduce each resulting matrix by logical OR.
o     Take the logical OR of the entries of the resulting maxtrix and the
corr. entries of M.
ḅ1   Convert each row from base 1 to integer, i.e. sum its elements.
M  Get all indices of maximal sums.
``````
``````×Ḅ|/€|ḄBS€M  Main link. Argument: M (matrix)

Ḅ           Convert each row of M from base 2 to integer. Result: R
×            Multiply the entries of each column of M by the corr. integer.
|/€        Reduce each row fo the resulting matrix by bitwise OR.
|Ḅ      Bitwise OR the results with R.
BS€   Convert to binary and reduce by sum.
This counts the number of set bits for each integer.
M  Get all indices of maximal popcounts.
``````

1

MattPutnam '16

2
@MattPutnam果冻使用其自己的自定义编码。（而且它也不是基于堆栈的）

2
@MattPutnam我也有类似的想法，但他们丝毫不减损传统的高尔夫运动。没有人会因为存在这些传统语言而看不起传统语言，而且与其他SE网站不同的是，这并不完全具有“这个答案比那个答案明显更好”。同样，尽管从技术上讲不允许这样做，但他们不会更改语言来支持问题（尽管事后他们可能会意识到将来的问题有用的捷径并进行操作）。
corsiKa

xnor

@Dennis我现在看到了，它的基本布尔矩阵乘法是通过逻辑或位运算完成的。实际的矩阵乘法会不会更短？
xnor

2

## Python使用numpy，54个字节

``````import numpy
lambda M:(M**0+M+M*M).all(1).nonzero()[0]``````

2

## JavaScript（ES6），83个字节

``````a=>a.map((b,i)=>b.every((c,j)=>c|i==j|b.some((d,k)=>d&a[k][j]))&&r.push(i),r=[])&&r
``````

Charlie Wynn

2

# MATL，12 10 9字节

``````Xy+HY^!Af
``````

``````4
[0,1,1,0; 0,0,1,0; 0,0,0,1; 1,1,0,0]
``````

``````20
[0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,1,0,1; 1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1; 0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,1; 0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1; 1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1; 0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1; 0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0; 1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,1,0; 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1; 1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,1,1,1; 1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0; 0,1,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1; 0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,1; 1,0,1,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1; 0,0,1,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1; 0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1; 0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1; 0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1; 1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0; 0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0]
``````

### 说明

``````Xy    % Implicitly take input: number. Push identity matrix with that size
+     % Implicitly take input: matrix. Add to identity matrix
HY^   % Matrix square
!     % Transpose
A     % Row vector with true entries for columns that contain all nonzero values
f     % Indices of nonzero values
``````

1
MATL <果冻\ m /

1

# 的Javascript 136 131 121 112字节

``````(n,m)=>m.map((a,k)=>eval(a.map((o,i)=>o||eval(a.map((p,j)=>p&&m[j][i]).join`|`)).join`+`)>n-2&&k+1).filter(a=>a)
``````

``````f=(n,m)=>m.map((a,k)=>eval(a.map((o,i)=>o||eval(a.map((p,j)=>p&&m[j][i]).join`|`)).join`+`)>n-2&&k+1).filter(a=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