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

×

SIGSEGV error in BLINNET

Here is the link to question : http://www.spoj.com/problems/BLINNET/ Link to my solution : https://repl.it/@NikhilAgrawal/BLINNET

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?

TIA!

asked 12 Mar, 22:39

kaneki13's gravatar image

4★kaneki13
395
accept rate: 0%


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)

link

answered 12 Mar, 23:59

rds_98's gravatar image

1★rds_98
305
accept rate: 4%

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
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×17

question asked: 12 Mar, 22:39

question was seen: 114 times

last updated: 13 Mar, 14:42