A1335 | [COCI-2016_2017-contest1]#2 Jetpack
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Little Mirko got a new mobile phone for his birthday! As all kids nowadays, he quickly downloaded all of the popular mobile games, including Jetpack Joyride.
In the game, the protagonist Barry is running across a field consisting of 10 rows and N columns of squares of equal size. Initially, Barry is located in the center of the square in the lower left corner. Barry is constantly running to the right at the speed of one square per second. Additionally, he must avoid obstacles that are in his way.
When Mirko presses the phone screen, Barry turns on his super-duper special jetpack and starts his ascent at the speed of one square per second (still moving to the right, now moving diagonally up at an angle of 45°, until he reaches the ceiling, when he will continue moving to the right until Mirko releases the screen). When Mirko releases the phone screen, Barry starts falling down at the speed of one square per second (now moving diagonally again, but this time facing down, until he reaches the floor, when he will continue moving to the right).
Mirko just started playing the game recently and he's still not good at it. He saw on YouTube that someone managed to complete the game by crossing all N columns, so he is asking you for your help. He will give you the layout of the fields in the game, and you must output the moves he has to play in order to win.
In the game, the protagonist Barry is running across a field consisting of 10 rows and N columns of squares of equal size. Initially, Barry is located in the center of the square in the lower left corner. Barry is constantly running to the right at the speed of one square per second. Additionally, he must avoid obstacles that are in his way.
When Mirko presses the phone screen, Barry turns on his super-duper special jetpack and starts his ascent at the speed of one square per second (still moving to the right, now moving diagonally up at an angle of 45°, until he reaches the ceiling, when he will continue moving to the right until Mirko releases the screen). When Mirko releases the phone screen, Barry starts falling down at the speed of one square per second (now moving diagonally again, but this time facing down, until he reaches the floor, when he will continue moving to the right).
Mirko just started playing the game recently and he's still not good at it. He saw on YouTube that someone managed to complete the game by crossing all N columns, so he is asking you for your help. He will give you the layout of the fields in the game, and you must output the moves he has to play in order to win.
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 10^5), the size of the field.
Each of the following 10 lines contains N characters '.' and 'X', the layout of the field in the game. The characters 'X' denote obstacles, and '.' walkable fields.
Each of the following 10 lines contains N characters '.' and 'X', the layout of the field in the game. The characters 'X' denote obstacles, and '.' walkable fields.
输出格式
The first line of output must contain the integer P (0 ≤ P ≤ 5·10^4), the number of moves Mirko has to make.
In the following P lines, output any series of P moves, each in its own line, such that it solves Mirko's problem from the task.
A move is determined by two integers ti and xi , where ti denotes the second in which Mirko has to press the screen, and xi denotes how long he needs to keep the screen pressed.
A series of moves must be sorted in chronological order. In other words, it must hold ti + xi ≤
ti+
1.
Also, no move should begin after the end of the game,
ti < N.
The input data will be such that a solution will surely exist.
In the following P lines, output any series of P moves, each in its own line, such that it solves Mirko's problem from the task.
A move is determined by two integers ti and xi , where ti denotes the second in which Mirko has to press the screen, and xi denotes how long he needs to keep the screen pressed.
A series of moves must be sorted in chronological order. In other words, it must hold ti + xi ≤
ti+
1.
Also, no move should begin after the end of the game,
ti < N.
The input data will be such that a solution will surely exist.
输入输出样例
输入 #1
11 .....XX...X ....XX...XX ...XX...XX. ........... ....XXX.... ........... .....X..... ....XX...X. ...XX...XX. ...X...XX..
输出 #1
2 1 4 7 2
输入 #2
20 X..................X .X................X. ..X..............X.. ...X............X... ....X..........X.... .....X........X..... ......X......X...... .......X....X....... ........X..X........ .........XX.........
输出 #2
1 8 10
The path Mirko has to take is denoted with '*':
```
.....XX...X
....XX...XX
...XX...XX.
...........
....XXX....
.....*...*.
....*X*.*.*
...*XX.*.X.
..*XX...XX.
**.X...XX..
```
```
.....XX...X
....XX...XX
...XX...XX.
...........
....XXX....
.....*...*.
....*X*.*.*
...*XX.*.X.
..*XX...XX.
**.X...XX..
```
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted