Segfault when trying to print out answer

Revision en1, by wzhang, 2019-10-22 23:27:58

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.

Tags segfault, #debug, #help, #newbie

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English wzhang 2019-10-22 23:27:58 778 Initial revision (published)