結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | okkuukenken |
提出日時 | 2022-09-02 21:36:15 |
言語 | C++23(draft) (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,420 ms / 3,000 ms |
コード長 | 993 bytes |
コンパイル時間 | 1,803 ms |
コンパイル使用メモリ | 155,384 KB |
実行使用メモリ | 15,176 KB |
最終ジャッジ日時 | 2023-08-10 03:31:28 |
合計ジャッジ時間 | 13,974 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 3 ms
4,376 KB |
testcase_17 | AC | 159 ms
14,720 KB |
testcase_18 | AC | 160 ms
14,732 KB |
testcase_19 | AC | 159 ms
14,860 KB |
testcase_20 | AC | 1,042 ms
15,176 KB |
testcase_21 | AC | 1,139 ms
15,096 KB |
testcase_22 | AC | 792 ms
14,968 KB |
testcase_23 | AC | 780 ms
15,096 KB |
testcase_24 | AC | 786 ms
15,004 KB |
testcase_25 | AC | 775 ms
15,020 KB |
testcase_26 | AC | 1,420 ms
15,012 KB |
testcase_27 | AC | 1,418 ms
15,052 KB |
testcase_28 | AC | 161 ms
14,752 KB |
testcase_29 | AC | 1,186 ms
14,996 KB |
testcase_30 | AC | 146 ms
14,048 KB |
ソースコード
#define _USE_MATH_DEFINES #include<iostream> #include<vector> #include<algorithm> #include<cmath> #include<string> #include<iomanip> #include<numeric> #include<queue> #include<deque> #include<stack> #include<set> #include<map> #include<random> #include<bitset> #include<cassert> #include<complex> #include<fstream> #include<cstdlib> #include<functional> #include<array> using namespace std; typedef long long ll; const int mod=998244353; int main(){ int h,w; string s[3000]; cin>>h>>w; for(int i=0;i<h;i++) cin>>s[i]; string ans={s[0][0]}; set<pair<int,int>>tmp={{0,0}}; for(int i=0;i<h+w-2;i++){ set<pair<int,int>>nxt; char c=-1; for(auto[x,y]:tmp){ if(x!=h-1){ if(c==-1||c>s[x+1][y]){ c=s[x+1][y]; nxt.clear(); } if(c==s[x+1][y]) nxt.insert({x+1,y}); } if(y!=w-1){ if(c==-1||c>s[x][y+1]){ c=s[x][y+1]; nxt.clear(); } if(c==s[x][y+1]) nxt.insert({x,y+1}); } } ans+=c; tmp.swap(nxt); } cout<<ans<<endl; }