introduction to online judges
Post on 13-Apr-2017
117 Views
Preview:
TRANSCRIPT
AUTOMATIC
EVALUATIONOF JAVA PROGRAM
THROUGH ONLINE JUDGE
TABLE OF CONTENTS
l What is an Online Judge?l l Difference between User-oriented
programs and Online Judge oriented programs
l l Why do we need Ojs?l l Practices to considerl l MOSS (Massive Online Software
Similarity)l
WHAT IS AN OJ? Online system
Compile and execute code
Test programs with pre-constructed data
Offline User Oriented Program
import java.io.*;public class Add{
public static void main(String args[])throws IOExeception{
int a, b, sum;BufferedReader br=new
BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter first number:”);
a=Integer.parseInt(br.readLine());System.out.println(“Enter
second number:”);
b=Integer.parseInt(br.readLine());sum=a+b;
System.out.println(“Sum=“ +sum);}}
Online Judge Oriented Program
import java.io.*;public class Add{
public static void main(String args[])throws IOExeception{
int a, b, sum;BufferedReader br=new
BufferedReader(new InputStreamReader(System.in));a=Integer.parseInt(br.readLine()); b=Integer.parseInt(br.readLine());
sum=a+b;
System.out.println(sum);}}
|||||||||||||||||||||||||
WHY DO WE NEED OJS? Test on multiple data Optimize code:
Time complexitySpace complexity
Large Input
TIME COMPLEXITY Time limit Input Constraints
INSTEAD OF THIS
public static void main(String args[])throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=new String();str=br.readLine();char c;for(int i=0; i<str.length(); i++){
c=str[i];System.out.println(c);
}
}
WE USE THISpublic static void main(String args[])throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=new String();str=br.readLine();char c;int len=str.length()for(int i=0; i<len; i++){
c=str[i];System.out.println(c);
}
}
SPACE COMPLEXITY
Example 1
vs
Example2
PRACTICES TO CONSIDER
Input Methods:Scanner << BufferedReader <<
BufferedInputStream Output Methods:
PrintWriter, PrintStream >> System.out.print
Input and Output Format
** ** * ** * * ** * * * *
** ** * ** * * ** * * * *
Expected Output
Ouput by Your Code
EXAMPLES SPOJ UVa TopCoder CodeForces CodeChef HackerRank HackerEarth
CODECHEF
Class name - Main DO NOT PRINT (“Enter a number”)
MOSS – THE BOSS
Plagiarism reporter Copy Case Different Variables
ANY QUESTION
S?
CONTACT US
MANSI JAIN (TE IT A):l mansi.j@somaiya.edu
KRUSHI GADA (TE IT A):l krushi.gada@somaiya.edu
VRISHABH LAKHANI (TE IT B):l vrishabh.l@somaiya.edu
THANK YOU
top related