Can anyone get me the solution of

Thanks in advance

Can anyone get me the solution of

Thanks in advance

I think you can refer to catlan number.

Thinking-

Catlna number denotes the number of “balanced bracket sequences” (known fact).

[Balance bracket sequences mean, The sequence of brackets of “{” and “}” is closed, eg “{{{}}}”.]

Assume husband to be ‘{’ and wife to be ‘}’ . Now, the condition reduces to, that, the brackets should be balanced.

(A bracket sequence can never be balanced if “}” comes before “{”-Equivalent to a wife sitting before her husband)

Try this approach and see if it works. If it doesnt, get back to me, didnt tested yet. Kind of stuck atm

Ok…I will try

Refer to wiki for catlan number. Geeksforgeeks for generation, or else you can simply store first 20 catlan numbers in an array and be done with. If it doesnt work, tell me.

It is not working in my case. I don’t know why. I just used the code of gfg to generate the Catalan numbers and printed as it was asked.

Have I done something wrong?

https://www.codechef.com/viewsolution/14895067

I am looking into it right now. Sorry for delay, things are coming up and keeping me busy.

The matter is solved. The test cases are INCORRECT (as i suspected- since its a excontest problem). The setter included the case for N=0 (for which he assumed answer to be 0) while constraints mention that N is between [1,20).

Also, i kind of dont agree with answer being 1 for N=0. You have nobody, so empty set could be an answer. Anyway, its just that, the constraints are incorrect. There is a case of N=0.

No problem, I can understand :

EDIT: Oh I wrote it for your previous comment. Btw Thanks. I was really wondering why it’s not working.

Correction -

```
i kind of dont agree with answer being 1 for N=0.
```

Its i kind of dont agree with answer being 0 for N=0, since we have empty set. Sorry for confusion, idk what was on my mind.

vijju123 has said rightly