TheOpChicken123's blog

By TheOpChicken123, history, 12 days ago,

I have been trying to solve a question but I have a bug in my code which I need to fix. I also have files with inputs and corresponding outputs for this question. However the problem is that the input files are extremely big (about 3.5MB). Therefore, I cannot run it on my laptop as I get a segfault (I am certain it is because of stack overflow when I am doing dfs as I have done many tests). And I cannot run it on any online compiler, including codeforces, because the input file is too big. Most websites only allow input as big as a few hundred KB.

So my question is — How am i supposed to run my code with this input? The online grader where I found this problem only tells me if I got a testcase right or wrong or TLE, MLE, etc. It doesn't tell me anything as to the difference between expected and my output. So what should i do?

Note: I can't really find any smaller testcases either and every testcase that I make myself seems to work.

Edit: If you guys want to try on your own computers, here is the code: https://pastebin.com/fnWh1Xbc. And here is the input: https://paste.ee/p/FJKWt Please let me know if you don't recieve a segfault. Also note that if you want to copy the input, view the file as raw (there is a button on the linked website).

Also, this is the debug code that I used to make sure that the segfault is because of stackoverflow: https://pastebin.com/w9WV7Znx

The only difference between the two pieces of code is that in the debug code, I output "second" right before I go to a new node and the first thing that I do when I am at a new node is output "first". When I do this, the last thing my program outputs is "second" which means that it is the very act of calling the function which produces a segfault, which must mean that it is stackoverflow. Note that the dfs function is called "calculate_city_info"

• -5

 » 12 days ago, # | ← Rev. 2 →   0 Have you tried running it through a file? For example ifstream fin("filename.in") in c++. I tried it on a 16 MB file and it ran succesfully.
•  » » 12 days ago, # ^ |   0 Yes, when i tried running it on my laptop i meant that i had put the input into a file then tried running it. It gave a segfault
•  » » » 12 days ago, # ^ | ← Rev. 2 →   0 Then, the problem isn't related to the test and the size of it. You can definitely run a test of that size.
•  » » » » 12 days ago, # ^ |   0 Ok i will edit the post with my code and my testcase. Can u try run my code on your laptop? Thanks
•  » » » » 11 days ago, # ^ |   -8 Hello, can you try running my code on your laptop please and see if you have a different result? Thanks. I have the code and input on my blog
 » 12 days ago, # |   0 #pragma comment(linker, "/STACK:102400000,102400000") add this at the beginning of the program
 » 12 days ago, # | ← Rev. 3 →   0 You may use  freopen("*.in","r",stdin); freopen("*.out","w",stdout); Then you can put the input to the *.in and the output is on the *.out
 » 12 days ago, # |   +5 In the Terminal or Command Prompt, cd to the folder that has your program. Then, after compiling your program, type something like ./programfile < inputfile > outputfile.This method has a great advantage in that you don't need to change anything on your code.
•  » » 12 days ago, # ^ |   0 I see i will try that in a while as i am on my phone right now
 » 12 days ago, # |   0 Auto comment: topic has been updated by TheOpChicken123 (previous revision, new revision, compare).