编程介的小学生 2017-10-24 12:27 采纳率: 20.5%
浏览 733
已采纳

Orienteering

问题描述 :

The Orienteering competition is coming soon!Now there are N players to participate in,each has his own cheering squad (lala dui) ,In order to ensure order and security competition,Each player’s cheering squad can only send 2*M beautiful mm ,M mm from North Campus,M mm from South Campus(as known that HNU consists of South Campus and North Campus)。
In order to facilitate management , the mm from the same Campus must stay at the same side of the road which means there are two Sequences and each Sequence has equal number of mm .The day of the race,each side has many positions starting from the finishing line toward the starting line numbered for the 1,2,3. . . . up to 2*n*m positions,every mm has her own favorite position,however, when she finds her favorite position is occupied by other students, she has to go to the next position, until she finds a empty position(the cost time of this process is negligible)。
For example, there is a mm whose favorite position is 3,when she goes to the position 3,there has a people over there,so she goes to the next position 4,however ,still has a people there ,until she gets the position 6 where no one occupies this position at present,so she`s position is 6,when all the people find their positions ,the teacher for the competition comes ,he finds that there are still some empty positions ,then he orders that all people move closer to the finishing line which can not change the relative positions of each mm at the both side,so finally their positon number is from 1 to n*m,now we get two sequence A,B A[i] means the mm on the ith position of this side support the player A[i],B[i] means the mm on the ith position of the opposite side support the player B[i].
Now the teacher has Picking a speaker , the mm supporting different players must wear different clothes, but those who support the same player should wear the same clothes. In order to make the venue more harmonious visual effect,to choose two sequence (A[c[1]],A[c[2]],……A[c[len]]) (B[d[1]],B[d[2]],…..B[d[len]]),A[c[i]]=Bd[i] The teacher want to know the max len,can you help us?Namely, you should find the max len such that there exists two identical subsequence with len elements in A and B respectively(these two subsequence need not to be continuous).
输入:

The first line of input should give the number of cases, T (at most 20).the first line of each case has two numbers n,m(1<=n<=10000,1<=m<=10)n represent the number of players,numbers from 1 to n ,m represent the number of mm of each players cheering squad,The next two lines,each with n*m*2 numbers,the i*2-1 number means the ith mms supported player number v[i](1<=v[i]<=n),the i*2 number means the ith mm`s faviourite positionwi, we set the mm number i is earlier than the mm number j when (i<j).
输出:

The first line of input should give the number of cases, T (at most 20).the first line of each case has two numbers n,m(1<=n<=10000,1<=m<=10)n represent the number of players,numbers from 1 to n ,m represent the number of mm of each players cheering squad,The next two lines,each with n*m*2 numbers,the i*2-1 number means the ith mms supported player number v[i](1<=v[i]<=n),the i*2 number means the ith mm`s faviourite positionwi, we set the mm number i is earlier than the mm number j when (i<j).
样例输入:

1
3 2
1 3 1 4 3 2 2 5 2 2 3 1
3 1 1 4 2 2 3 1 2 4 1 3
样例输出:

Case #1: 4

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-07 14:38
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘