A1226 | [COCI-2011_2012-contest3]#1 DIGITALNA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A while ago, Mirko’s grandparents had to switch from analog to digital TV receiver. On their old analog receiver they could watch only two channels: BLJTV1 and BLJTV
2. Switching to digital receiver they gained dozens of new channels, but they still wanted to watch just the two channels they had before. They asked Mirko to adjust the remote control in a way that BLJTV1 is on first and BLJTV2 on the second key.
When switched on, digital receiver creates a list of available channels. All of the channels are distinct and the list always contains BLJTV1 and BLJTV
2. Mirko found the remote and he started adjusting the receiver. Menu contains the channel list and a little arrow which is marking the currently selected channel. After entering the menu, the arrow is marking the first channel on the list.
There are four operations in the menu, denoted with numbers 1 to 4:
1. move the arrow one place down (from channel i to channel i+1)
2. move the arrow one place up (from channel i to channel i-1)
3. move the arrow and selected channel one place down (channel i and channel i+1 are switching places, arrow ends up in place i+1)
4. move the arrow and selected channel one place up (channel i and channel i-1 are switching places, arrow ends up in place i-1)
Menu is robust, so invalid commands (such as a command which would move the arrow outside of the channel list) are just ignored.
Write a program which will, given a channel list, output a sequence of any operations such that, after they are executed, BLJTV1 will be on the first, and BLJTV2 on the second place in channel list.
Additionally, the sequence length should be less than 50
0. Ordering of all other channels is arbitrary.
2. Switching to digital receiver they gained dozens of new channels, but they still wanted to watch just the two channels they had before. They asked Mirko to adjust the remote control in a way that BLJTV1 is on first and BLJTV2 on the second key.
When switched on, digital receiver creates a list of available channels. All of the channels are distinct and the list always contains BLJTV1 and BLJTV
2. Mirko found the remote and he started adjusting the receiver. Menu contains the channel list and a little arrow which is marking the currently selected channel. After entering the menu, the arrow is marking the first channel on the list.
There are four operations in the menu, denoted with numbers 1 to 4:
1. move the arrow one place down (from channel i to channel i+1)
2. move the arrow one place up (from channel i to channel i-1)
3. move the arrow and selected channel one place down (channel i and channel i+1 are switching places, arrow ends up in place i+1)
4. move the arrow and selected channel one place up (channel i and channel i-1 are switching places, arrow ends up in place i-1)
Menu is robust, so invalid commands (such as a command which would move the arrow outside of the channel list) are just ignored.
Write a program which will, given a channel list, output a sequence of any operations such that, after they are executed, BLJTV1 will be on the first, and BLJTV2 on the second place in channel list.
Additionally, the sequence length should be less than 50
0. Ordering of all other channels is arbitrary.
输入格式
First line of input contains a positive integer N (2 ≤ N ≤ 100), number of channels.
Next N lines contain a list of channels generated by the digital receiver. Each line contains the name of one channel. Channel name is a sequence of at most 10 characters - capital letters of English alphabet and digits.
Input sequence is created in such way that it will always be required to make at least one operation.
Next N lines contain a list of channels generated by the digital receiver. Each line contains the name of one channel. Channel name is a sequence of at most 10 characters - capital letters of English alphabet and digits.
Input sequence is created in such way that it will always be required to make at least one operation.
输出格式
First and only line of output should contain the sequence of Mirko’s commands with no spaces in between.
输入输出样例
输入 #1
3 ABC BLJTV1 BLJTV2
输出 #1
33
输入 #2
4 ABC1 ABC02 BLJTV2 BLJTV1
输出 #2
11144411144
输入 #3
4 ABC1 ABC02 BLJTV2 BLJTV1
输出 #3
33144413
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted