Sie sind auf Seite 1von 4

€

Archives of the Gia?i bai tru+.c tuye^’n


main problemset
€

Editors:
Fernando Torres

Last updated: 2010-03-07 02:38:38

1
Preface
This electronic material contains a set of algorithmic problems, forming the archives of the Gia?i bai
tru+.c tuye^’n (http://www.spoj.pl/SPOJVN/), main problemset. The document can be accessed at the
following URLs:

in PostScript format: http://www.spoj.pl/SPOJVN/problems/main.ps


in Portable Document Format: http://www.spoj.pl/SPOJVN/problems/main.pdf

These resources are constantly updated to synchronise with the ever-changing hypertext version of the
problems, and to include newly added problems. If you have obtained this document from another
source, it is strongly recommended that you should download the current version from one of the
aforementioned URLs.

Enjoy problem-solving at the Gia?i bai tru+.c tuye^’n!

Disclaimer from the Editors. Despite our best efforts, it is possible that this document contains errors or that some of the
content differs slightly from its original hypertext form. We take no responsibility for any such faults and their
consequences. We neither authorise nor approve use of this material for any purpose other than facilitating problem solving
at the Sphere Online Judge site; nor do we guarantee its fitness for any purpose whatsoever.

The layout of the problems in this document is the copyright of the Editors named on the cover (as determined by the
appropriate footers in the problem description). The content is the copyright of the respective Editor unless the copyright
holder is otherwise stated in the ’resource’ section. The document as a whole is not protected by copyright, and fragments
of it are to be regarded independently. No responsibility is taken by the Editors if use or redistribution of this document
violates either their or third party copyright laws. When referring to or citing the whole or a fragment of this document,
please state clearly the aforementioned URLs at which the document is to be found, as well as the resources from which the
problems you are referring to originally came.

Remarks concerning this document should be sent to the following e-mail address: contact@spoj.pl.

2
Table of Contents
1. Problem CARDS (6247. Tráo bai)

3
SPOJ Problem Set (main)

6247. Tráo bai


Problem code: CARDS
Cho bô bai gôm n lá bai đu+o+.c xe^’p thanh day thu+’ tu+. tu+‘ 1 to+’i n, đâu tien ngu+o+‘i ta ghi
vao môi lá bai môt sô nguyen la sô thu+’ tu+. ban đâu cu?a lá bai đó. Xét phép tráo S(i,m,j) : Lây ra
kho?i bô bai m lá lien tie^’p băt đâu tu+‘ lá bai thu+’ i, sau đó chen m lá bai nay vao tru+o+’c lá bai
thu+’ j trong sô n-m lá bai con la.i 1<=i,j<=n-m+1. Quy u+o+’c ne^’u j = n-m thi m lá bai lây ra se~
đu+o+.c đu+a vao cuôi day

Ví du. vo+’i n = 9

Bô bai ban đâu : (1,2,3,4,5,6,7,8,9)

Thu+.c hie^.n S(1,5,2) : (1,2,3,4,5,6,7,8,9) -> (6,1,2,3,4,5,7,8,9)

Thu+.c hie^.n tie^’p S(5,4,6) : (6,1,2,3,4,5,7,8,9) -> (6,1,2,3,9,4,5,7,8)

Thu+.c hie^.n tie^’p S(8,2,1) : (6,1,2,3,9,4,5,7,8) -> (7,8,6,1,2,3,9,4,5)

Yeu câu : Hay cho bie^’t sô ghi tren các lá bai sau khi thu+.c hie^.n x phép tráo bai cho tru+o+’c

Input
€- Dong 1 : Chu+’a 2 sô nguyen n va x (n,x <= 10^5)

€- x dong tie^’p theo la bô ba sô nguyen i,m,j la môt phép tráo S(i,m,j)

Output
€ Gôm 1 dong duy nhât chu+’a n sô nguyen. sô thu+’ i la sô ghi tren lá bai thu+’ i.

Example
Input:
9 31 5 25 4 68 2 1Output:
7 8 6 1 2 3 9 4 5

Added by: Fernando Torres


Date: 2010-03-05
Time limit: 1s-2.5s
Source limit:50000B
Languages: All except: TCL SCALA ERL TECS JS
Resource: Mr. Le Minh Hoang

Das könnte Ihnen auch gefallen