ONLINE_JUDGE

This is the place where you should ask for those features you would like to see on the COJ, or to suggest te ways in which we can improve our service. Every contribution is valuable, don't be afraid to make yours!
Post Reply
rlac
Posts: 7
Joined: 9 years ago
Gender: None specified

ONLINE_JUDGE

Post by rlac » 9 years ago

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.



george
Posts: 43
Joined: 9 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by george » 9 years ago

rlac wrote:Hi. Some online judges like SPOJ and TIMUS compile the codes (at least in C++), defining the macro ONLINE_JUDGE.
Can you post some advances of this??

rlac
Posts: 7
Joined: 9 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by rlac » 9 years ago

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;
}

User avatar
ymondelo20
Posts: 1968
Joined: 9 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: ONLINE_JUDGE

Post by ymondelo20 » 9 years ago

rlac wrote:Hi. Some online judges like SPOJ and TIMUS compile the codes (at least in C++), defining the macro ONLINE_JUDGE.
Codeforces use that, like this others.
:D
"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

rlac
Posts: 7
Joined: 9 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by rlac » 9 years ago

So ... :?:

george
Posts: 43
Joined: 9 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by george » 9 years ago

it will be include it soon!!!

mgear
Posts: 4
Joined: 8 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by mgear » 8 years ago

How do does macros help define? I've seen various judge use it in their compilation: -DONLINE_JUDGE and i know thats for

Code: Select all

#ifdef ONLINE_JUDGE
// code
#endif
but i dont know how that helps.

kangoonie
Posts: 4
Joined: 8 years ago
Gender: None specified

Re: ONLINE_JUDGE

Post by kangoonie » 8 years ago

Please define it too in java compilators.
In Codeforces they use:
java.exe -Xmx256M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s
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.

Post Reply

Return to “Suggestions”