Why this solution got AC ?! I couldn't understand. Can someone hack this solution ?!
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Why this solution got AC ?! I couldn't understand. Can someone hack this solution ?!
Название |
---|
This is a totally normal solution
AC solution with random ?!
During the contest I wanted to do this and I wrote the solution but I was afraid to submit it :D
I think that nobody can hack a randomized solution purposely.
In fact rand() % n must be less than 32767, because codeforces is in WINDOWS. And the solution does this 3000000 times, the probability that [0,32767) is perfectly covered is very high, according to the editorial, either of the number of two candies will be less than , also less than 32767, therefore the solution is correct and cannot be hacked.
(2016.09.08 updated — now rand() in win10 will yield numbers in [0, 2^31)).
elin sokdunay jigim
Perfect solution XD
tohdon has already explained what's going here, I'll add that when you are using proper random generator such as
mt19937
, this solution fails on third test with TL (original 10606822) or WA (10606853, number of attempts divided by 4).