結果
問題 | No.572 妖精の演奏 |
ユーザー |
|
提出日時 | 2018-06-18 10:30:03 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 701 ms |
コンパイル使用メモリ | 123,692 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 01:15:02 |
合計ジャッジ時間 | 1,421 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!long - 1; auto M = readln.chomp.to!int; auto A = M.iota.map!(_ => readln.split.map!(to!long).array).array; auto B = new long[][](M, M); long[][] mul(const long[][] a, const long[][] b) { auto ret = new long[][](M, M); foreach (i; 0..M) foreach (j; 0..M) ret[i][j] = a[i][j]; foreach (i; 0..M) foreach (j; 0..M) foreach (k; 0..M) ret[j][k] = max(ret[j][k], a[j][i] + b[i][k]); return ret; } while (N) { if (N & 1) B = mul(B, A); A = mul(A, A); N >>= 1; } B.map!(b => b.reduce!max).reduce!max.writeln; }