| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
| Name |
|---|



it also give same wrong answer for C++11
your 'tot' operation look unbehaviour
it should be
X[tot + 1] = X[tot] + 1, tot++;You mean that the operation
++totdoesn't same in C++17 and C++14 ? sorry for my poor English.He means "undefined behavior". It's a kind of coding error and you shouldn't do that.
it also got accepted with C++ 11 ,here:61043518
I could not find any operation for this behaviour.
Since it failed on 2nd test case so you can put debug statement with condition (n==5) so it won't fail on 1 case and you can know where it start changing behaviour.
If you find the mistake please update in post as well, i would like to know where it fail
See This answer in stack-overflow. In your submission
X[++tot] = X[tot-1] + 1; is undefined behavior for c++ versions less than c++17: The left hand side of the = operator can be executed before or after the right hand side. In c++17, it's guaranteed that the right side will be executed before the left side. I think you assumed that in X[tot-1] tot's value was increased by 1 because of X[++tot], but actually tot is increasing later.Thanks again ShafinKhadem !
See This answer in stack-overflow. In your submission
X[++tot] = X[tot-1] + 1;is undefined behavior for c++ versions less than c++17: The left hand side of the = operator can be executed before or after the right hand side. In c++17, it's guaranteed that the right side will be executed before the left side. I think you assumed that in X[tot-1] tot's value was increased by 1 because of X[++tot], but actually tot is increasing later.Thank you very much.
That's not only the execution order is undefined. The entire expression is undefined. Anything can happen.
See http://www.eskimo.com/~scs/readings/undef.950321.html .
thank you very much,Chinese friend