結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-04 03:44:36 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 940 bytes |
| コンパイル時間 | 949 ms |
| コンパイル使用メモリ | 120,580 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 07:11:15 |
| 合計ジャッジ時間 | 1,501 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 9 |
ソースコード
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop;
immutable long MOD = 1_000_000_007;
void main(){
char[] buf; readln(buf);
auto input = buf.split.to!(int[]);
auto N = input[0], M = input[1];
auto st = new int[][](N, N);
foreach(i ; 0 .. M){
readln(buf);
input = buf.split.to!(int[]);
auto a = input[0], b = input[1], score = input[2];
st[a][b] = score;
}
auto ans = bitDP(N, st);
writeln(ans);
}
int bitDP(int N, int[][] st){
auto uni = 2^^N - 1;
auto dp = new int[][](uni + 1, N);
foreach(s ; 0 .. uni + 1){
foreach(v ; 0 .. N){
auto s2 = s & (uni ^ 1<<v);
foreach(u ; 0 .. N){
if(s2 & 1<<u) dp[s][v] = max(dp[s][v], dp[s2][u] + st[u][v]);
}
}
}
return dp[uni].reduce!(max);
}