A1134 | [COCI-2007_2008-contest6]#4 PRINCEZA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Luka parked his truck near the lake. The lake is inhabited by the frog Barica, who jumps across N plants floating on the lake's surface. Knowing a fair number of folk tales, Luka knows that if he kisses Barica, she will turn into a beautiful princess. However, he needs to catch her first!
Assuming an aerial view, the position of a plant on the lake's surface can be defined with a pair of coordinates. From plant (x, y) Barica can jump:
• To plant (x+P, y+P), for any positive integer P. Call this direction A.
• To plant (x+P, y−P), for any positive integer P. Call this direction B.
• To plant (x−P, y+P), for any positive integer P. Call this direction C.
• To plant (x−P, y−P), for any positive integer P. Call this direction D.
Barica selects one of the four directions and jumps onto the first plant in the chosen direction. If there is no plant in the selected direction, Barica stays where she is. After Barica jumps, the plant she jumped from sinks and disappears.
Knowing the locations of the plants and the sequence of directions Barica chooses, Luka wants to determine coordinates of the plant Barica will end up on. Luka will wait for her at that plant, ambush her and kiss her.
Write a program that solves Luka's problem and helps him turn Barica into a beautiful princess.
Assuming an aerial view, the position of a plant on the lake's surface can be defined with a pair of coordinates. From plant (x, y) Barica can jump:
• To plant (x+P, y+P), for any positive integer P. Call this direction A.
• To plant (x+P, y−P), for any positive integer P. Call this direction B.
• To plant (x−P, y+P), for any positive integer P. Call this direction C.
• To plant (x−P, y−P), for any positive integer P. Call this direction D.
Barica selects one of the four directions and jumps onto the first plant in the chosen direction. If there is no plant in the selected direction, Barica stays where she is. After Barica jumps, the plant she jumped from sinks and disappears.
Knowing the locations of the plants and the sequence of directions Barica chooses, Luka wants to determine coordinates of the plant Barica will end up on. Luka will wait for her at that plant, ambush her and kiss her.
Write a program that solves Luka's problem and helps him turn Barica into a beautiful princess.
输入格式
The first line contains two integers N and K (1 ≤ N, K ≤ 100 000), the number of plants and the number of attempted jump.
The second line contains K letters each of which is 'A', 'B', 'C' or 'D'. These letters represent in order the directions in which Barica attempts to jump.
Each of the following N lines contains two integers X and Y (0 ≤ X ≤ 1 000 000 000,
0 ≤ Y ≤ 1000000000), the coordinates of one plant. Barica is initially located on the first plant.
The second line contains K letters each of which is 'A', 'B', 'C' or 'D'. These letters represent in order the directions in which Barica attempts to jump.
Each of the following N lines contains two integers X and Y (0 ≤ X ≤ 1 000 000 000,
0 ≤ Y ≤ 1000000000), the coordinates of one plant. Barica is initially located on the first plant.
输出格式
Output Barica's final coordinates.
输入输出样例
输入 #1
7 5 ACDBB 5 6 8 9 4 13 1 10 7 4 10 9 3 7
输出 #1
7 4
输入 #2
6 12 AAAAAABCCCDD 1 1 2 2 3 3 4 4 5 3 6 2
输出 #2
5 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted