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



Here is the link to question : Link to my solution :

While submitting the solution, it's showing sigsegv error which occurs due to invalid memory referrence but I don't see that happening in my code. I have already tried for more than a hour to fix it but to no avail. Can someone please help me find it?


asked 12 Mar, 22:39

kaneki13's gravatar image

accept rate: 16%

Why are you using const in

bool comp(const node l,const node r) {
    return l.cost < r.cost;

second, you are using long long int at every place which you don't need to.

and you are using

lld root(lld nodes) {
if (parent[nodes] != nodes)
    parent[nodes] = root(parent[nodes]);
return parent[nodes];

which might call recursively many time itself maybe causing that error.

use only int main() instead of int main(void)


answered 12 Mar, 23:59

rds_98's gravatar image

accept rate: 9%

edited 13 Mar, 00:00

That is not the case because when I replace my edge array with vector it passed which simply signifies that comp and root function don't have any bug!

(13 Mar, 14:42) kaneki134★
toggle preview

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 Mar, 22:39

question was seen: 149 times

last updated: 13 Mar, 14:42