Please sign in first.
提出 #11046860
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;
/**
* Contest : AtCoder Grand Contest 043
* Contest URL : https://atcoder.jp/contests/agc043
* Problem :
* Problem URL :
*/
void solve() {
int H, W;
cin >> H >> W;
vector < string > matrix (H);
for (int i = 0; i < H; i++) {
cin >> matrix[i];
}
vector < vector < int > > dp (H, vector < int > (W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (i == 0 && j == 0) {
dp[i][j] = (matrix[i][j] == '#');
} else if (i == 0) {
dp[i][j] = dp[i][j - 1] + (matrix[i][j] == '#');
} else if (j == 0) {
dp[i][j] = dp[i - 1][j] + (matrix[i][j] == '#');
} else {
dp[i][j] = min (dp[i - 1][j], dp[i][j - 1]) + (matrix[i][j] == '#');
}
}
}
cout << dp[H - 1][W - 1] << endl;
}
int main() {
int T = 1;
//scanf ("%d", &T);
while (T--) {
solve();
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Range Flip Find Route |
| ユーザ | himanshup |
| 言語 | Python (3.4.3) |
| 得点 | 0 |
| コード長 | 963 Byte |
| 結果 | RE |
| 実行時間 | 17 ms |
| メモリ | 2940 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00, example_01, example_02, example_03 |
| All | corner_00, corner_01, example_00, example_01, example_02, example_03, kuronuri_00, max_answer_00, max_answer_01, max_answer_02, max_random_00, max_random_01, max_random_02, max_random_03, one_path_00, one_path_01, one_path_02 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| corner_00 | RE | 17 ms | 2940 KiB |
| corner_01 | RE | 17 ms | 2940 KiB |
| example_00 | RE | 17 ms | 2940 KiB |
| example_01 | RE | 17 ms | 2940 KiB |
| example_02 | RE | 17 ms | 2940 KiB |
| example_03 | RE | 17 ms | 2940 KiB |
| kuronuri_00 | RE | 17 ms | 2940 KiB |
| max_answer_00 | RE | 17 ms | 2940 KiB |
| max_answer_01 | RE | 17 ms | 2940 KiB |
| max_answer_02 | RE | 17 ms | 2940 KiB |
| max_random_00 | RE | 17 ms | 2940 KiB |
| max_random_01 | RE | 17 ms | 2940 KiB |
| max_random_02 | RE | 17 ms | 2940 KiB |
| max_random_03 | RE | 17 ms | 2940 KiB |
| one_path_00 | RE | 17 ms | 2940 KiB |
| one_path_01 | RE | 17 ms | 2940 KiB |
| one_path_02 | RE | 17 ms | 2940 KiB |