Surprise Language Round 8

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
683 Surprise Language Round 8 FINISHED False 9000 310399185 June 16, 2016, 4 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 123 ) H Exchange of Books PROGRAMMING *special 2100

N pupils, who love to read books, study at school. It is known that each student has exactly one best friend, and each pupil is the best friend of exactly one other pupil. Each of the pupils has exactly one interesting book. The pupils decided to share books with each other. Every day, all pupils give their own books to their best friends. Thus, every day each of the pupils has exactly one book. Your task is to use the list of the best friends and determine the exchange of books among pupils after k days. For simplicity, all students are numbered from 1 to n in all tests. The first line contains two integers n and k ( 2 ≤ n ≤ 100000, 1 ≤ k ≤ 10 16 ) — the number of pupils and days during which they will exchange books. The second line contains n different integers a i ( 1 ≤ a i ≤ n ), where a i is equal to the number of the pupil who has the best friend with the number i . It is guaranteed that no pupil is the best friend of himself. In a single line print n different integers, where i -th integer should be equal to the number of the pupil who will have the book, which the pupil with the number i had in the beginning, after k days. The explanation to the first test. There are 4 pupils and 1 day. The list of the best friends equals to {2, 4, 1, 3}. It means that: the pupil with the number 3 — is the best friend of pupil with the number 1, the pupil with the number 1 — is the best friend of pupil with the number 2, the pupil with the number 4 — is the best friend of pupil with the number 3, the pupil with the number 2 — is the best friend of pupil with the number 4. After the first day the exchange of books will be {3, 1, 4, 2}. the pupil with the number 3 will have the book, which the pupil with the number 1 had in the beginning, the pupil with the number 1 will have the book, which the pupil with the number 2 had in the beginning, the pupil with the number 4 will have the book, which the pupil with the number 3 had in the beginning the pupil with the numbe

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
18526575 .tx H June 16, 2016, 5:03 p.m. OK Kotlin TESTS 53 202 819200 2100
18527612 dalex H June 16, 2016, 5:35 p.m. OK Kotlin TESTS 53 202 3072000 2100
40984278 ReaLNero1 H July 30, 2018, 7:17 p.m. OK Kotlin TESTS 53 217 3174400 2100
23365293 Ali.Pi H Dec. 27, 2016, 6:44 p.m. OK Kotlin TESTS 53 217 22425600 2100
18526867 IgorAkhmetov H June 16, 2016, 5:12 p.m. OK Kotlin TESTS 53 218 2150400 2100
18528572 bintree H June 16, 2016, 6:08 p.m. OK Kotlin TESTS 53 233 102400 2100
18529070 noxwell H June 16, 2016, 6:24 p.m. OK Kotlin TESTS 53 233 204800 2100
18526472 pitfall H June 16, 2016, 4:59 p.m. OK Kotlin TESTS 53 233 6553600 2100
18528063 jasperH H June 16, 2016, 5:50 p.m. OK Kotlin TESTS 53 280 6860800 2100
61392821 PavelChadnov H Sept. 27, 2019, 11:08 p.m. OK Kotlin TESTS 53 296 6144000 2100

remove filters

Back to search problems