searleser97 / cpbooster

Competitive Programming Booster
GNU General Public License v3.0
144 stars 30 forks source link

While testing my code code is showing wrong if I use debug file #92

Closed MdNihal05 closed 10 months ago

MdNihal05 commented 10 months ago

When we use our own debug template which prints output for us

For example like this

For more clarity see here

We can submit without removing the debug functions

But when we test using:Test or cpb test it gives WA

It should ignore debug statements and compare actual output

How to fix that any modifications in config file ?

searleser97 commented 10 months ago

I am not allowed to see your second link, and the first one is not loading, anyways I think this is more related to how your debug functions are written, at the moment there is no config around debug statements

searleser97 commented 10 months ago

Please take a closer look to the section linked below , specially notice the special flag -DDEBUG which helps us to just include parts of the code only when that flag is set. Then obviously codeforces does not set that flag and therefore the debugging code is not included at all in the execution, neither your compile/execution command should include that flag.

https://searleser97.github.io/cpbooster/docs/debug#print-debug-lines-in-red-in-c

MdNihal05 commented 10 months ago

thanks for looking in to the issue

i update the link you can see here

and my config file is attached below Screenshot from 2023-08-29 23-10-23

and my issue is attached below Screenshot from 2023-08-29 23-13-13

i submited the code and got accepted but where i run cpbooster test file.cpp it showing error because of the debug statements

how should i debug can you share any picture or something so that i can understand here is my templete and this is my debug

searleser97 commented 10 months ago

your debug statements should no be printing when running Test, could you send an screenshot of the output of your program without using cpbooster? Like compiling with the same command that you have in the config, and then just executing as normal to see if there is any difference in the output

MdNihal05 commented 10 months ago

you can see here Screenshot from 2023-08-29 23-42-53

and i can't submit when iam using proxy since i use college proxy iam getting error

can you fix that

searleser97 commented 10 months ago

That is the output without your flag ? Then that is the problem, why your debug statements get printed even when you are not passing the debug flag ?

searleser97 commented 10 months ago

For the proxy thing please create a different issue in this repo, will try to investigate and see if there is something I can do about it

MdNihal05 commented 10 months ago

it is because i called debug function inside my code you can see my accepted submission this is what i generally do to check my output there is not way to fix it ?

and for proxy thing i will create a new issue thanks

searleser97 commented 10 months ago

so, your code should not print any debugging text if you did NOT set the flag -DONLINEJUDGE

It should only print them if you set the flag, there is something you are doing on local that is not same as in codeforces, can't figure out what it is yet.

searleser97 commented 10 months ago

Could you literally run the :Test command with the code from the codeforces link? I mean copy and paste it from codeforces, not from your local machine, and see what is the output in cpbooster

MdNihal05 commented 10 months ago

i copied the same code i submitted before and i cloned problem and them submitted the same code so i can test but giving wa because of debug statements

i habituate to looking the outputs by calling debug function if it is correct than i will sumit it directly

even i did the same here it got sumitted successfully but when i test it it showing wa

so was curious to solve the issue without commenting the debug(....) function in my code

it's taking too long sorry for the inconvenience and can't we see the status of submissoin in vim itself ?

searleser97 commented 10 months ago

I just reproduced the issue

MdNihal05 commented 10 months ago

?

searleser97 commented 10 months ago

so, I just learned that "codeforces" add the flag "ONLINE_JUDGE" so basically you are doing the opposite, you are saying in your code: If you DON'T see the "ONLINE_JUDGE" flag then print debug stuff, otherwise just hide it, the issue is that then you should add this "ONLINE_JUDGE" flag in the "compilation command"

searleser97 commented 10 months ago

so that the command from codeforces and from cpbooster is the same

searleser97 commented 10 months ago

however, I do recommend changing it to the opposite I don't think the "ONLINE_JUDGE" is added by all judges, therefore this might not be compatible if you submit to some other place like AtCoder, OmegaUp, etc...

In the link I sent before I explained how to do it with the "DEBUG" flag instead of "ONLINE_JUDGE"

https://searleser97.github.io/cpbooster/docs/debug#print-debug-lines-in-red-in-c

MdNihal05 commented 10 months ago

you are saying that i should add debugCommand : g++ -std=gnu++17 -ONLINE_JUDGE -Wshadow -Wall instead of debugCommand : g++ -std=gnu++17 -DONLINE_JUDGE -Wshadow -Wall

or something else

can you tell me where should i change the command what should i add for specially codeforce because i haven't tried other you can tell here changing flag specially for codeforces

searleser97 commented 10 months ago

debug command should not include any flag for your code to work, but then in "command" you should include it

MdNihal05 commented 10 months ago

you mean i should remove `#ifdef ONLINE_JUDGE debug(...);

endif`

from my code ?

searleser97 commented 10 months ago

no

searleser97 commented 10 months ago

just modify the "config" file

searleser97 commented 10 months ago
  "languages": {
    "cpp": {
      "template": "",
      "command": "g++ -std=gnu++17 -DONLINE_JUDGE -O2",
      "debugCommand": "g++ -std=gnu++17 -Wshadow -Wall",
MdNihal05 commented 10 months ago

which statement should i add to this


 13      cpp : {
 14        template : "",
 15        command :  g++ -std=gnu++17 -O2 ,
 16        debugCommand :  g++ -std=gnu++17 -DONLINE_JUDGE -Wshadow -Wall ,
 17        aliases : {
 18          codeforces :  54 ,
 19          atcoder :  4003 ,
 20          omegaup :  cpp17-gcc ,
 21          szkopul :  C++ ,
 22          yandex :  gcc7_3 
 23       },
 24        type :  compiled ,
 25        commentString :  // 
 26     },```
MdNihal05 commented 10 months ago

ok thanks i will try this

MdNihal05 commented 10 months ago

it worked thanks for your patience and you can close this issue if you can help me with proxy stuff try to fix it please

searleser97 commented 10 months ago

however I do recommend to do the opposite as I explain in the documentation link, ONLINE_JUDGE flag will only work for codeforces but not other judge, and I also recommend understanding your template entirely

MdNihal05 commented 10 months ago

why iam getting this error for atcoder
iam new to atcoder so i created account and tried to submit i even tried by changing config to default Screenshot from 2023-08-30 01-38-48

MdNihal05 commented 10 months ago

its working fine for codeforces