Блог пользователя TheOpChicken123

Автор TheOpChicken123, история, 2 года назад, По-английски

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
  • Проголосовать: не нравится

»
2 года назад, # |
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.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 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

    • »
      »
      »
      2 года назад, # ^ |
      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.

      • »
        »
        »
        »
        2 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Ok i will edit the post with my code and my testcase. Can u try run my code on your laptop? Thanks

      • »
        »
        »
        »
        2 года назад, # ^ |
          Проголосовать: нравится -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

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
#pragma comment(linker, "/STACK:102400000,102400000") 

add this at the beginning of the program

»
2 года назад, # |
  Проголосовать: нравится +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.

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by TheOpChicken123 (previous revision, new revision, compare).