結果
問題 | No.971 いたずらっ子 |
ユーザー | kotamanegi |
提出日時 | 2020-01-17 21:34:46 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 1,063 bytes |
コンパイル時間 | 6,145 ms |
コンパイル使用メモリ | 164,336 KB |
実行使用メモリ | 42,624 KB |
最終ジャッジ日時 | 2024-11-07 11:24:44 |
合計ジャッジ時間 | 7,668 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
main.cpp:1:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas] 1 | #pragma comment (linker, "/STACK:256000000") | ^ 1 warning generated.
ソースコード
#pragma comment (linker, "/STACK:256000000") #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; typedef string::const_iterator State; #define eps 1e-11L #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144 #define pb push_back #define mp make_pair typedef long long ll; #define REP(a,b) for(long long (a) = 0;(a) < (b);++(a)) #define ALL(x) (x).begin(),(x).end() void init() { iostream::sync_with_stdio(false); cout << fixed << setprecision(100); } #define int ll int dist[3000][3000]; void solve() { int h, w; cin >> h >> w; REP(i, h) { REP(q, w) { dist[i][q] = 1e18; } } dist[0][0] = 0; REP(i, h) { string s; cin >> s; REP(q, s.length()) { int cost = 1; if (s[q] == 'k') { cost += llabs(i + q); } if (i != 0) { dist[i][q] = min(dist[i - 1][q] + cost, dist[i][q]); } if (q != 0) { dist[i][q] = min(dist[i][q - 1] + cost, dist[i][q]); } } } cout << dist[h - 1][w - 1] << endl; } #undef int int main() { init(); solve(); }