Submission #11046860
Source Code Expand
#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;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Range Flip Find Route |
| User | himanshup |
| Language | Python (3.4.3) |
| Score | 0 |
| Code Size | 963 Byte |
| Status | RE |
| Exec Time | 17 ms |
| Memory | 2940 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 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 |