×

# Feasible Relations

 0 Feasible Relations Solution Link I have used Union-find data structure and the basic idea is to first process all queries having '=' and then processing all queries with "!=". I am getting SIGSEGV error For 4 out of 7 testcases could anybody tell where am i going wrong??? asked 12 Aug, 23:36 3★divik544 252●6 accept rate: 6% i am unaware about the oop memory related concepts in c++ so is it due to them (12 Aug, 23:38) divik5443★

 1 Your approach is correct. The problem lies in the if block on line 75 if(uf.root(a)==uf.root(b)) { ans="NO"; break; } When this condition is triggered you are breaking out the loop where you are taking input. So you're moving onto the next test case without completely reading the inputs of the current test case. This naturally causes the actual leftover input to differ from the expected format which results in runtime error. Just remove the if block and your code runs fine, since you are checking all "!=" cases later anyway from the qu vector! :) answered 13 Aug, 00:22 6★meooow 3.7k●3●8 accept rate: 49% awesome thanks it worked!! :) (13 Aug, 06:34) divik5443★
 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:

×281
×70