编程介的小学生 2017-08-08 16:00 采纳率: 20.5%
浏览 703
已采纳

Calendar of Events

Description

Marketing people are very creative and must regularly attend many creative meetings. In the past, the meetings used to repeat every week. Now, there are so many of them, that the period must have been changed to one month.

The monthly schedule of ACM now contains one meeting for each of the first N days in every month (including weekends). Meetings are identified by non-negative integer numbers. Recently, ACM found out that the schedule must be reorganized and the order of meetings changed. The new order has already been chosen. The only problem is that the meeting-planning department has very limited privileges and must follow many directives that are in effect.

It fact, the only change that the department is allowed to do, is to issue a request to reverse the order of meetings in the first D days of the month (D may be selected arbitrarily). For example, if the current schedule is “1 2 3 4 5” and the department issues a request to reverse the first 3 days, the new schedule will be “3 2 1 4 5”.

Another limitation is that the department is allowed to issue only one request per week. Since they need the whole reorganization to finish in one year, the number of requests may not exceed 52. As you can see, their situation is not easy. Will you help?
Input

The input contains a sequence of several reorganizations, the last one followed by a line with zero.

Each reorganization consists of three lines: the first line contains a positive integer N — the number of days in month that are considered, 1 ≤ N ≤ 30. The second line describes the old schedule and the third line the new schedule, each of them contains N meeting identifiers, separated with spaces. Some meetings may appear more than once.
Output

For each reorganization, output a single line containing at most 52 positive integer numbers D1, D2, ..., Dk separated by a space (1 ≤ Di ≤ N). The numbers must form a valid sequence of requests that will be issued to transform the old schedule to the new one.

You are guaranteed that such a sequence will exist. If there are more valid sequences, feel free
to output any of them.
Sample Input

5
1 4 8 9 10
4 8 9 10 1
0
Sample Output

5 4

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-22 16:28
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题