Had it been given that the sequence of integers p1,p2..pn is not necessarily a permutation, it would have been a more interesting problem ! How will we solve this modified version of the problem?
№ | Пользователь | Рейтинг |
---|---|---|
1 | jiangly | 3898 |
2 | tourist | 3840 |
3 | orzdevinwang | 3706 |
4 | ksun48 | 3691 |
5 | jqdai0815 | 3682 |
6 | ecnerwala | 3525 |
7 | gamegame | 3477 |
8 | Benq | 3468 |
9 | Ormlis | 3381 |
10 | maroonrk | 3379 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 168 |
2 | -is-this-fft- | 165 |
3 | Dominater069 | 161 |
4 | Um_nik | 159 |
4 | atcoder_official | 159 |
6 | djm03178 | 157 |
7 | adamant | 153 |
8 | luogu_official | 151 |
9 | awoo | 149 |
10 | TheScrasse | 146 |
Had it been given that the sequence of integers p1,p2..pn is not necessarily a permutation, it would have been a more interesting problem ! How will we solve this modified version of the problem?
Название |
---|
Maybe you find amount of strongly connected components ?
Not really, 2, 3, 4, 5, 6, 5 needs just one change!
I didn't read the statement carefully and thought this was the condition and tried to solve the harder problem, but failed due to missing a case. :(
Same here :(
Same here :D I solved the harder version in the contest :D
I guess just one extra change has to be made if components = 1 and graph is not cycle then ans++
Nope, it will fail on this test :
7 2 3 4 7 6 1 6
0 1 0 0 0 0 0
what's the answer in that case? isn't it 5?