結果

問題 No.2064 Smallest Sequence on Grid
ユーザー QCFiumQCFium
提出日時 2022-09-02 21:30:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 175,004 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2024-04-27 20:55:51
合計ジャッジ時間 5,616 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 226 ms
15,232 KB
testcase_27 WA -
testcase_28 AC 157 ms
14,976 KB
testcase_29 AC 134 ms
14,976 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int h = ri();
	int w = ri();
	std::string s[h];
	for (auto &i : s) std::cin >> i;
	
	std::string res{s[0][0]};
	std::vector<int> cur = {0};
	for (int i = 1; i < h + w - 1; i++) {
		std::vector<int> xs;
		for (auto j : cur) {
			if (!xs.size() || xs.back() < j) xs.push_back(j);
			if (j + 1 < h && (!xs.size() || xs.back() < j + 1)) xs.push_back(j + 1);
		}
		char min = 'z' + 1;
		std::vector<int> mindex;
		for (auto x : xs) {
			if (i - x < 0 || i - x >= w) continue;
			if (min > s[x][i - x]) {
				min = s[x][i - x];
				mindex = {x};
			} else if (min == s[x][i - 1]) mindex.push_back(x);
		}
		assert(mindex.size());
		cur = mindex;
		res.push_back(min);
	}
	std::cout << res << std::endl;
	return 0;
}
0