CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February Long Contest
    • January CookOff
    • January Long Contest
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Help

Help

The CodeChef System

  • Compilers
  • Source code length restriction
  • Execution time restriction
  • Memory restriction
  • Input Output

Example

  • Solution in C
  • Solution in PASCAL
  • Solution in Java
  • Submitting Solutions

Technical Issues related to C/C++

  • Debugging at home

Technical issues related to other OS system users

  • New line encoding
  • Using 64-bit number types

The CodeChef System

Submitted solutions are automatically compiled and run under Linux test system. You must keep strictly the input output specification. In particular your program must not printout any additional messages like 'input the number please', which are not specified in the problem formulation.

Compilers

Submitted solutions are compiled according to the user selection made during the submission process. For example:

  • gcc 4.0.0-8 (with standard library) for C language.
  • g++ 4.0.0-8 (with Standard Template Library) for C++ language.
  • fpc 2.0.4 (with standard `library end Delphi extension for FreePascal) for Pascal language.
  • j2se jdk 5.0 with standard library (excluding some multimedia, network and system interaction classes). Starting point for Java programs is public static void main (String[] a) method in Main class, which must be defined.
  • other compilers are accessible depending on chosen programming language: C 99strict, D, C#, Nemerle, Haskell, O'Caml, Prolog, Scheme, Lips, Clips, Icon, Whitespace, Fortran, Smalltalk, Ada95, Assembler (Nasm), Intercal, Php, Pike, Ruby, Perl, Brainf**k.

Source code length restriction

Source code length is restricted to 50 000 bytes in a one file. Additional restrictions might be provided for particular problems. Using external libraries or files is prohibited.

Execution time restriction

Execution time is restricted for each problem and for each test case separately. In each case restriction is not severer then 1s. Solutions are tested on equal PIII 733 MHZ processors.

Memory restriction

Accessible memory is at least 64MB.

Input Output

Program should read from standard input and write into standard output. There is no need to read all data first, compute them all and then print all output. It is recommended to read and write data as simultaneously. Technically, server redirects standard stream to files. You can test you programs in the same way at home.

Example

Task: write the program for sum two integers. On input two integers A and B. On output sum of these integers.

Input example:

2 3

Output example:

5

Solution in C:

#include <stdio.h>
int main() { int a, b; scanf("%d %d", &a, &b); printf("%d\n",a+b); return 0; }

Solution in PASCAL:

program ex;
var a, b: integer;
begin
read(a,b);
writeln(a+b);
end.

Solution in Java:

public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader
(new java.io.InputStreamReader (System.in));
int a=Integer.parseInt(r.readLine()),
b=Integer.parseInt(r.readLine());
System.out.println(a+b);
}
}

Solution submitting

To submit a solution choose problem from list of problems and press button 'Submit' at the top of the problem description. You can submit multiple solutions to each problem. Score for the problem is equal to the score of the best submitted solution.

To see the Statistic for problem choose problem from list of problems and press button 'All submissions' at the top of the problem description. To view the status, hover over the check box, cross or warning icon in the result column.

At present the following status codes are available:

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. The specific error codes are:
    • SIGSEGV(signal 11) - most common, 'segmentation fault';
    • SIGXFSZ (signal 25) - 'output limit exceeded';
    • SIGFPE (signal 8) - 'floating point error' - like division by zero, etc.;
    • SIGABRT (signal 6) - raised by the program itself; In C and C++ macro assert does it while fails, also C++ STL does it under some conditions;
    • NZEC (non-zero exit code) - helps telling crash from WA with interpreted languages;
    • other - there are other signals which can cause program to terminate, all remaining are shown as other.

Technical issues related to C/C++

Debugging at home

You could use symbolic constant ONLINE_JUDGE for debugging purpose. In C you can use:

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

Input data are taken from input.txt, and output data are print to output.txt only outside the CodeChef system.

Technical issues related to other OS system users

New line encoding

Please consider it important that a new line characters can differ between Linux and other OS. It might be a cause of malicious bugs.

Using 64-bit number types

If you use a compiler in which a long long type does not exist (like MS VisualC++) then to assure proper compilation you can create a symbolic constant:

#define __int64 long long

In this case do not forget about proper output format:

%lld instead of %I64d in the case of using scanf/printf functions.

 

Directi Go for Gold

NEWS FEED:

 
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com