You are not logged in. Please login at to post your questions!


[closed] Feasible Relations

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 '17, 23:36

divik544's gravatar image

accept rate: 11%

closed 26 Aug '17, 15:53

i am unaware about the oop memory related concepts in c++ so is it due to them

(12 Aug '17, 23:38) divik5444★

The question has been closed for the following reason "The question is answered, right answer was accepted" by divik544 26 Aug '17, 15:53

Your approach is correct. The problem lies in the if block on line 75


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 '17, 00:22

meooow's gravatar image

6★meooow ♦
accept rate: 49%

awesome thanks it worked!! :)

(13 Aug '17, 06:34) divik5444★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 12 Aug '17, 23:36

question was seen: 241 times

last updated: 26 Aug '17, 15:53