結果
| 問題 | 
                            No.2064 Smallest Sequence on Grid
                             | 
                    
| コンテスト | |
| ユーザー | 
                             QCFium
                         | 
                    
| 提出日時 | 2022-09-02 21:30:02 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 801 bytes | 
| コンパイル時間 | 1,558 ms | 
| コンパイル使用メモリ | 175,676 KB | 
| 実行使用メモリ | 15,232 KB | 
| 最終ジャッジ日時 | 2024-11-16 02:22:30 | 
| 合計ジャッジ時間 | 6,037 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 10 WA * 19 | 
ソースコード
#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;
}
            
            
            
        
            
QCFium