F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Shuffle Card

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3662    Accepted Submission(s): 1584


Problem Description
A deck of card consists of $n$ cards. Each card is different, numbered from 1 to n. At first, the cards were ordered from 1 to $n$. We complete the shuffle process in the following way, In each operation, we will draw a card and put it in the position of the first card, and repeat this operation for $m$ times.

Please output the order of cards after $m$ operations.
 

Input
The first line of input contains two positive integers $n$ and $m$.(1<=$n,m$<=$10^5$)

The second line of the input file has n Numbers, a sequence of 1 through $n$.

Next there are m rows, each of which has a positive integer $s_i$, representing the card number extracted by the $i$-th operation.
 

Output
Please output the order of cards after m operations. (There should be one space after each number.)
 

Sample Input
5 3 1 2 3 4 5 3 4 3
 

Sample Output
3 4 1 2 5
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 21:16:41, Gzip enabled