結果
| 問題 | No.572 妖精の演奏 | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-07 07:50:13 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 487 ms / 2,000 ms | 
| コード長 | 539 bytes | 
| コンパイル時間 | 387 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 44,480 KB | 
| 最終ジャッジ日時 | 2024-10-14 11:37:49 | 
| 合計ジャッジ時間 | 11,517 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
# %%
N = int(readline())
M = int(readline())
A = np.array(read().split(), np.int64).reshape(M, M)
# %%
def merge(A, B):
    return (A[:, :, None] + B[None, :, :]).max(axis=1)
# %%
def power(A, n):
    if n == 1:
        return A
    B = power(A, n // 2)
    B = merge(B, B)
    if n % 2 == 0:
        return B
    return merge(A, B)
# %%
print(power(A, N - 1).max())
            
            
            
        