×

# Help required

 0 Can anyone get me the solution of https://www.codechef.com/COWH2017/problems/COWHR102/ Thanks in advance asked 09 Aug, 19:32 894●8 accept rate: 9% @vijju123 How to count...any idea ? (09 Aug, 19:52)

 0 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 :( answered 09 Aug, 23:40 4★vijju123 7.4k●2●12 accept rate: 17% Ok...I will try (10 Aug, 00:22) 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. (10 Aug, 00:24) vijju1234★ 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 (10 Aug, 14:55) @vijju123 Will you please have a look. (10 Aug, 17:27) I am looking into it right now. Sorry for delay, things are coming up and keeping me busy. (10 Aug, 17:54) vijju1234★ 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. (10 Aug, 18:35) vijju1234★ 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.:) (10 Aug, 20:21) 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. (10 Aug, 20:25) vijju1234★ showing 5 of 8 show all
 0 vijju123 has said rightly answered 13 Aug, 01:21 11●2 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,557