結果
問題 |
No.971 いたずらっ子
|
ユーザー |
![]() |
提出日時 | 2020-01-18 09:00:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 1,185 bytes |
コンパイル時間 | 1,477 ms |
コンパイル使用メモリ | 116,720 KB |
最終ジャッジ日時 | 2025-01-08 19:56:09 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<bitset> #include<set> #include<map> #include<stack> #include<queue> #include<deque> #include<list> #include<iomanip> #include<cmath> #include<cstring> #include<functional> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 using ll = long long; using Pi = pair<int,int>; using Pl = pair<ll,ll>; ll dp[2020][2020]; int main(){ int H,W; cin >> H >> W; vector<string> a(H); rep(i,H) cin >> a[i]; rep(i,2020)rep(j,2020) dp[i][j] = LINF; dp[0][0] = 0; rep(i,H)rep(j,W){ if(i+1 < H){ if(a[i+1][j] == '.') dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1); else dp[i+1][j] = min(dp[i+1][j],dp[i][j]+i+j+2); } if(j+1 < W){ if(a[i][j+1] == '.') dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1); else dp[i][j+1] = min(dp[i][j+1],dp[i][j]+i+j+2); } } //rep(i,H)rep(j,W) cout << dp[i][j] << endl; cout << dp[H-1][W-1] << endl; }