Hello Everyone !!
Can Someone explain me why this solution gave TLE Verdict ??
# | User | Rating |
---|---|---|
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 |
# | User | Contrib. |
---|---|---|
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 |
Hello Everyone !!
Can Someone explain me why this solution gave TLE Verdict ??
Name |
---|
TLE is time limit exceeded. Which simply means make your code more efficient.
I agree, But I wanted to know which part in my code is causing such inefficiency!!
I think (a[j]<<1) part it is not required actually u can simply check __gcd(a[i],2*a[j])> 1 || __gcd(2*a[i],a[j])>1 then count++
Yes, you are right That works But (a[j]<<1) is equal to a[j]*2 and is faster, That should not cause TLE Right??
Maybe it's yours overloaded sort, try this, maybe it'll help: Also yours output is empty maybe infinite loop
when sorting if compare function have 2 odd or 2 even numbers it's output will give different
Your comparator is wrong, it has to implement strict weak ordering, which essentially means that comparator should return
true
if you for sure want first element before second andfalse
in any other case (including if you don't care about order)The correct comparator would be
Thanks a Ton Maksim1744, Learnt a new thing today :)
You can just use
return a % 2 < b % 2;
(https://codeforces.me/contest/1535/submission/118369895)Just like how the shortest solution sorts with
key = lambda x: x%2
.All you should know about comparator in C++
Thank You smit.mangukiya
Your comparator function is wrong .... You may have simply used greater()
Thank you h1teshtr1path1