QingdaoU / OnlineJudge

Open source online judge based on Vue, Django and Docker. | 青岛大学开源 Online Judge | QQ群 496710125 | admin@qduoj.com
http://opensource.qduoj.com/
MIT License
6.12k stars 1.49k forks source link

do not throw "Time Limited Exceed" #408

Open duchuyvp opened 2 years ago

duchuyvp commented 2 years ago

Hi. I want to create server online for my class. I have tried many online judge but I like yours. I have a question that your judge do not throw "Time Limited Exceed" when I have double for-loop with 1e6.

Excample in C++:

vector<long long> a(1,0);
for (int i = 0; i<1e6; i++)
    for(int j = 0; j<1e6; j++)
        a[0] = i*j;

I set time limit is 1000ms but this code do not give "Time Limited Exceed".

I also see that the judge only throw "Time Limited Exceed" when I have infinity loop in submited code. Please help.

rrutwik commented 2 years ago

@duchuyvp Check how C, C++ compiler works. It tries to optimize code when it runs, hence it does not throw error. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

You can remove "-O2" from command.

You need to make changes in https://github.com/QingdaoU/OnlineJudge/blob/64ef15420a993cbe598423d96e7024e3037ae78c/judge/languages.py#L78

"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++14 {src_path} -lm -o {exe_path}",

"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c11 {src_path} -lm -o {exe_path}"