0% found this document useful (0 votes)
84 views

Competitve Programming

The document discusses organizing a workshop on competitive programming and problem solving. The workshop agenda includes discussing how to improve the computer science syllabus, using online tools for teaching, developing problem-solving assignments in languages like C++ and Java, and using online judges. The document also defines competitive programming, explains its benefits for students and teachers, and provides tips for getting started with practicing on online judges.

Uploaded by

gaurav joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Competitve Programming

The document discusses organizing a workshop on competitive programming and problem solving. The workshop agenda includes discussing how to improve the computer science syllabus, using online tools for teaching, developing problem-solving assignments in languages like C++ and Java, and using online judges. The document also defines competitive programming, explains its benefits for students and teachers, and provides tips for getting started with practicing on online judges.

Uploaded by

gaurav joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Workshop on Competitive

Programming & Problem Solving

Anand Shenoi, Amrita University


anand[at]am.amrita.edu
Workshop Agenda & Outcomes
• CBSE Computer Science Syllabus discussion
– How to improve the syllabus
– How to train students for higher studies
– Expectation of the IT industry
– How to categorize talented students
• Online tools to enhance teaching and learning
• Develop C++ / Java / Python assignments
with problem solving approach
• Use online judges
Who am I?
• Started teaching in 1998 at Amrita Kochi
• Teaching till 2011 – Programming, Operating
Systems, Object Oriented Design, Data
Structures
• Currently Admission Coordinator
• Regional Contest Director, ACM ICPC
• Train students on Competitive Programming
CBSE Syllabus
• Why not use Linux environment? C++11,
C++14
• Using real time application examples
• How are C++ / Java / Python assignments
evaluated?
• How do you make students think?
• Creating interest in students
What is Competitive Programming?
• Tries to solve an unsolved problem
• Write most efficient solution in terms of
– Time
– Space
– Data
CP by a Top Coder
You are in the jungle. You have a pocket-knife. Someone asks you to
kill a mountain lion.
Years of training has taught you well. You use your knife to sharpen a
stick. You cut vines to lash sharp stones on one end. Maybe you're from
a top university, and you've learned to extract essential ingredients from
plant and insect life around you to fashion a poison to tip your weapon
with.
Convinced that you have an effective and efficient way to kill the lion, you
set forth to accomplish your task. Maybe your stick is too short, or your
poisons don't work. It's okay - you live to refine your method and try
again another day.
That's "real-life" programming.
In competitive programming, you start out with the same resources
(a pocket-knife), except you have 2 minutes to kill the lion.
Why CP?
• Best brain exercise for aspirants
• Improves the analytical skill
• Aspiring students learn to work under
pressure
• Students will start thinking out of the box
• Exhibit their creativity and programming talent
• Evolve the best, efficient solution
• Utilize the features of the language
Ex: Given 5 web pages find which page is good in
“C++ tutorials”.
What it really is!
Algorithm

Prog.
Language CP Maths

Data
Structures
Benefits for teachers
• Make programming classes more interesting
• Example 1, Example 2
• Use online judges for evaluation
• Be a PROUD teacher – how?
– Make them compete in Olympiads
– Bring laurels to your school
– Inspire the next generation
• Online judges even prevents plagiarism
What is a problem set?
A problem statement typically explained with a
story line. Eg:
Hari and Class Marks
Hari is a multi-talented person, and prepares
results for his college in his free time. (Yes,
he is still in love with his old college!) He
gets a list of students with their marks. The
maximum marks which can be obtained in the exam
is 100.
Hari is supposed to arrange the list in such
that student with highest mark appears first.
And if two students have the same marks, they
should be arranged in lexicographical manner.
Help Hari prepare to the same!
Components in a problem set
• Problem Statement
• Constraints
– Limitation on the input / output values
– Specific data type to be used
• Input Values
• Expected Output
• Input Format
• Output format
• Test Cases
Components in detail….
• Constraints
– Limitation on the input / output values
– Specific data type to be used
In a program where the number of students
can’t be more than 100.
Decimal values not more than two
No negative values allowed
Length of name
Components in a problem set
• Input Values
3
Eve 78
Bob 99
Alice 78

• Expected Output
Bob 99
Alice 78
Eve 78
Components in a problem set
• Input format:
On the first line of the standard input,
there is an integer N, denoting the number
of students. N lines follow, which contain
a string and an integer, denoting the name
of the student and his marks.
• Output format:
You must print the required list.
Important..
• Collection of expected input and corresponding
output
• It can by of any type of value
• Number of test cases increases based on the
complexity of the problem statement
• Some test cases may succeed and some may
fail
• Success means program has to pass all test
cases
What is an online judge?
• Program that evaluates your source code
• Compiles & executes online
• Verifies the correctness
• Tells you whether your program passed all the
test cases
• Tells you whether your program passed the
time constraint
• Tells you whether your program passed the
memory constraint
Possible Results
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.
Time Limit Exceeded Your program was compiled successfully,
but it didn't stop before time limit. Try optimizing your approach.
Wrong Answer Your program compiled and ran successfully but
the output did not match the expected output.
Runtime Error Your code compiled and ran but encountered an
error. The most common reasons are using too much memory or
dividing by zero. For the specific error codes see the help section.
Compilation Error Your code was unable to compile. When you
see this icon, click on it for more information.
How to start practicing?
• Register in any online judge
• Read the problem set
• Understand the input values carefully
• Understand expected output and its format
• Try solving in the local computer
• Give input values
• See the output values
• Submit in the online judge
• Most online judges are in Unix. So, use
CodeBlocks IDE
1. Register in CodeChef
2. Go to Practice->Beginner
3. Scroll down
4. Chose the problem with maximum submissions
5. Read the problem statement and start solving
with pen and paper
6. Write the code in the editor – Any language
7. Submit -> Debug if needed
8. Read the editorial if there is any doubt
9. Editorial
Why wait?

Start Coding!

Thank You!

You might also like