wzhang's blog

By wzhang, history, 12 months ago, In English

I was doing the following problem: https://codeforces.com/problemset/problem/1244/D, and was very confused when I tried to add code to print out the answer at lines 120-123, it segfaults at line 57 according to gdb. When I remove the code to print out the answer, no segfault occurs. I am incredibly confused. I removed all pragma's and macros, additional libraries, etc. and this error still persists. Does anyone have an idea why this is happening?

Here is the code: https://pastebin.com/ufrxhLtR Compiled with g++ -Wall -g with no errors or warnings, output of gbd when run:

Program received signal SIGSEGV, Segmentation fault. 0x0000555555554b4b in main () at 1244D.cpp:57 57 cin >> N;

Thanks in advance.

Read more »

  • Vote: I like it
  • +1
  • Vote: I do not like it