結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | kokatsu |
提出日時 | 2022-11-29 01:36:40 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 2,488 ms / 3,000 ms |
コード長 | 1,402 bytes |
コンパイル時間 | 2,694 ms |
コンパイル使用メモリ | 204,188 KB |
実行使用メモリ | 55,660 KB |
最終ジャッジ日時 | 2023-09-04 19:09:54 |
合計ジャッジ時間 | 22,717 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,384 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 3 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 3 ms
4,376 KB |
testcase_17 | AC | 292 ms
19,996 KB |
testcase_18 | AC | 290 ms
20,060 KB |
testcase_19 | AC | 290 ms
20,316 KB |
testcase_20 | AC | 1,860 ms
39,312 KB |
testcase_21 | AC | 1,992 ms
55,584 KB |
testcase_22 | AC | 1,411 ms
39,140 KB |
testcase_23 | AC | 1,397 ms
55,604 KB |
testcase_24 | AC | 1,389 ms
55,616 KB |
testcase_25 | AC | 1,399 ms
55,660 KB |
testcase_26 | AC | 2,488 ms
55,540 KB |
testcase_27 | AC | 2,477 ms
55,656 KB |
testcase_28 | AC | 292 ms
19,644 KB |
testcase_29 | AC | 2,083 ms
55,636 KB |
testcase_30 | AC | 269 ms
18,988 KB |
ソースコード
import std; struct Grid { int x, y; int opCmp(Grid that) { if (this.x != that.x) { if (this.x > that.x) return 1; else return -1; } if (this.y != that.y) { if (this.y > that.y) return 1; else return -1; } return 0; } } void main() { int H, W; readf("%d %d\n", H, W); auto S = new string[](H); foreach (i; 0 .. H) readf("%s\n", S[i]); string res = S[0][0].to!string; Grid[] list; list ~= Grid(0, 0); foreach (i; 2 .. H+W) { bool[Grid] nxt; dchar mn = 'z'; foreach (l; list) { if (l.x + 1 < H) { if (S[l.x+1][l.y] < mn) { nxt.clear; nxt[Grid(l.x+1, l.y)] = true; mn = S[l.x+1][l.y]; } else if (S[l.x+1][l.y] == mn) { nxt[Grid(l.x+1, l.y)] = true; } } if (l.y + 1 < W) { if (S[l.x][l.y+1] < mn) { nxt.clear; nxt[Grid(l.x, l.y+1)] = true; mn = S[l.x][l.y+1]; } else if (S[l.x][l.y+1] == mn) { nxt[Grid(l.x, l.y+1)] = true; } } } res ~= mn; list = nxt.keys; } res.writeln; }