ONLINE_JUDGE
ONLINE_JUDGE
Hi. Some online judges like SPOJ and TIMUS compile the codes (at least in C++), defining the macro ONLINE_JUDGE, and thus we can use it for execute code only in our PC and not when the code will be running in the judge. I think that COJ should compile defining this macro too.
Re: ONLINE_JUDGE
Can you post some advances of this??rlac wrote:Hi. Some online judges like SPOJ and TIMUS compile the codes (at least in C++), defining the macro ONLINE_JUDGE.
Re: ONLINE_JUDGE
I use it for manage input/output and see the total time in which run my program, for example, initially my main method is:
Code: Select all
int main()
{
//Input region
#ifndef ONLINE_JUDGE
system("notepad.exe name.in");
freopen("name.in", "r", stdin);
FILE * FILE_NAME = freopen("name.out", "w", stdout);
int TIME = clock();
#endif
//Add your code here...
//Output region
#ifndef ONLINE_JUDGE
cout << (clock() - TIME) << endl;
fclose(FILE_NAME);
system("notepad.exe name.out");
#endif
return 0;
}
- ymondelo20
- Posts: 1968
- Joined: 9 years ago
- Location: Universidad de las Ciencias Informáticas
- Gender:

- Contact:
Re: ONLINE_JUDGE
Codeforces use that, like this others.rlac wrote:Hi. Some online judges like SPOJ and TIMUS compile the codes (at least in C++), defining the macro ONLINE_JUDGE.
"Every problem has a simple, fast and wrong solution" OJ's Main Law. 
Re: ONLINE_JUDGE
How do does macros help define? I've seen various judge use it in their compilation: -DONLINE_JUDGE and i know thats for
but i dont know how that helps.
Code: Select all
#ifdef ONLINE_JUDGE
// code
#endifRe: ONLINE_JUDGE
Please define it too in java compilators.
In Codeforces they use:
In Codeforces they use:
This is useful to do IO redirection to files if we are offline, and to specify standard io if we are in the Online Judge System.java.exe -Xmx256M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s