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

Автор kk_ducviet, 10 лет назад, По-английски

Most coders read input from file and write out to another, but some online judge likes CodeForces use stdin. When solving problems in a contest, eveyone always want to minimum submission time, these little code may help:

C/C++

#ifndef ONLINE_JUDGE
freopen(fi, "r", stdin);
freopen(fo, "w", stdout);
#else
// online submission
#endif

Pascal

{$IFDEF ONLINE_JUDGE}
{online submission}
{$ELSE}
{read & write file}
{$ENDIF}   

Why? Because on the online judge, ONLINE_JUDGE is defined to be true in C/C++

Notice that it also works on UVa, some others too but I didn't test it :)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится