Skip to content

Commit

Permalink
e200: Add intelligent driving
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Sep 18, 2024
1 parent eeed4ea commit 51871de
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,6 @@
- [猴子吃桃/爱吃蟠桃的孙悟空 - 二分查找](od/2024e200/monkey-eats-peach/index.md)
- [机器人活动区域 - DFS](od/2024e200/moving-area-of-robot/index.md)
- [简易压缩算法/一种字符串压缩表示的解压 - 字符串](od/2024e200/compress-string/index.md)
- [智能驾驶 - 二分查找](od/2024e200/intelligent-driving/index.md)

[参考资料](refs.md)
1 change: 1 addition & 0 deletions src/od/2024e200/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
19. [猴子吃桃/爱吃蟠桃的孙悟空 - 二分查找](monkey-eats-peach/index.md)
20. [机器人活动区域 - DFS](moving-area-of-robot/index.md)
21. [简易压缩算法/一种字符串压缩表示的解压 - 字符串](compress-string/index.md)
22. [智能驾驶 - 二分查找](intelligent-driving/index.md)
7 changes: 7 additions & 0 deletions src/od/2024e200/intelligent-driving/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "e200-intelligent-driving"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
3 changes: 3 additions & 0 deletions src/od/2024e200/intelligent-driving/assets/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2,2
10,20
30,40
5 changes: 5 additions & 0 deletions src/od/2024e200/intelligent-driving/assets/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4,4
10,30,30,20
30,30,-1,10
0,20,20,40
10,-1,30,40
5 changes: 5 additions & 0 deletions src/od/2024e200/intelligent-driving/assets/input3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4,5
10,0,30,-1,10
30,0,20,0,20
10,0,10,0,30
10,-1,30,0,10
5 changes: 5 additions & 0 deletions src/od/2024e200/intelligent-driving/assets/input4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4,4
10,30,30,20
30,30,20,10
10,20,10,40
10,20,30,40
1 change: 1 addition & 0 deletions src/od/2024e200/intelligent-driving/assets/output1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
70
1 change: 1 addition & 0 deletions src/od/2024e200/intelligent-driving/assets/output2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
70
1 change: 1 addition & 0 deletions src/od/2024e200/intelligent-driving/assets/output3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
60
1 change: 1 addition & 0 deletions src/od/2024e200/intelligent-driving/assets/output4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1
92 changes: 92 additions & 0 deletions src/od/2024e200/intelligent-driving/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 智能驾驶

## 题目描述

有一辆汽车需要从 m * n 的地图左上角起点开往地图的右下角终点, 去往每一个地区都需要消耗一定的油量, 加油站可进行加油.

请你计算汽车确保从从起点到达终点时所需的最少初始油量.

说明:

- 智能汽车可以上下左右四个方向移动
- 地图上的数字取值是 0 或 -1 或 正整数
- -1, 表示加油站, 可以加满油, 汽车的油箱容量最大为100;
- 0: 表示这个地区是障碍物, 汽车不能通过
- 正整数: 表示汽车走过这个地区的耗油量
- 如果汽车无论如何都无法到达终点, 则返回 -1

### 输入描述

- 第一行为两个数字, M, N, 表示地图的大小为 M * N, 0 < M,N ≤ 200
- 后面一个 M * N 的矩阵, 其中的值是 0 或 -1 或正整数, 加油站的总数不超过 200 个

### 输出描述

如果汽车无论如何都无法到达终点, 则返回 -1.
如果汽车可以到达终点, 则返回最少的初始油量.

### 示例1

输入:

```text
{{#include assets/input1.txt}}
```

输出:

```text
{{#include assets/output1.txt}}
```

说明: 行走的路线为 `右→下`

### 示例2

输入:

```text
{{#include assets/input2.txt}}
```

输出:

```text
{{#include assets/output2.txt}}
```

说明: 行走的路线为 `右→右→下→下→下→右`

### 示例3

输入:

```text
{{#include assets/input3.txt}}
```

输出:

```text
{{#include assets/output3.txt}}
```

说明: 行走的路线为 `下→下→下→右→右→上→上→上→右→右→下→下→下`

### 示例4

输入:

```text
{{#include assets/input4.txt}}
```

输出:

```text
{{#include assets/output4.txt}}
```

说明: 无论如何都无法到达终点.

## 题解
3 changes: 3 additions & 0 deletions src/od/2024e200/intelligent-driving/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit 51871de

Please sign in to comment.