Problem link : https://toph.co/p/unbelievable-array How should I approach this problem? Someone help please.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Problem link : https://toph.co/p/unbelievable-array How should I approach this problem? Someone help please.
Название |
---|
First,hash all the indexes with same values with distinct integers i.e, if the given array is 1 2 3 2 1 4 2 1 , indexes 1,5,8 will be hashed to 1 , indexe(s) 2,4,7 will be hashed to 2, indexe(s) 3 will be hashed to 3 , indexe(s) 6 will be hashed to 4 and also store their corresponding values ! Now if you want to change index x in the original array to some y , go to the hashed index of x and update its value to y and if you want to query the index x in the original array , go to the hashed index of x and print its value ! I have not submitted the solution for this , just an idea ! My first comment on CF ! Please ignore if there are any mistakes !
Let's see how can we apply disjoint set here.
First initialize the parents of each number from 1 to 100000.
For type 1 operation set the parent of x as y.
For type 2 operation print the parent of a[idx].