machhra's blog

By machhra, history, 5 years ago, In English

Why did this solution TLE but it passed when I converted the lambda functions to normal ones? Am I doing something wrong here or can lambda functions have this big an overhead?

  • Vote: I like it
  • +28
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
 
Vote: I like it +67 Vote: I do not like it

Your pragmas are the culprit. Remove them and you'll get AC. Submission: https://codeforces.me/contest/1580/submission/138986509

Lambda functions are not to blame here.

»
5 years ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

I'm not sure about your particular scenario but in general lambda functions are a zero cost abstraction.

In fact, due to their narrower scope, the compiler can make stronger assumptions about their use, leading to better optimizations.