Getting familiar with ACM Contest. What is ACM ACM: Association for Computing Machinery o o the world’s largest.

Slides:



Advertisements
Similar presentations
1 ACM Programming Contest Nov 3, Introduction ACM organized such contests from1977 Contest Regional Qualifying Final Purpose provides college.
Advertisements

ACM Programming Team Bill Punch. ACM Programming Contest One of the premier programming competitions. Held every year since 1977 MSU was the winner that.
How to Begin… ?.
Advanced Programming 15 Feb The “OI” Programming Process Reading the problem statement Thinking Coding + Compiling Testing + Debugging Finalizing.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
A Review. a review of lessons learned so far… ( 2 steps forward - 1 step back) Software Development Cycle: design, implement, test, debug, document Large.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
0 Advanced Selection CE : Introduction to Software Development Week 3 Lecture 2.
Copyright 2006 by Pearson Education 1 reading: 4.1 Cumulative sum.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Computer Science 1620 Programming & Problem Solving.
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
The break and continue statements. Introduction There are 2 special statements that can affect the execution of loop statements (such as a while-statement)
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Computer Science 210 Computer Organization Introduction to C.
1 Software John Sum Institute of Technology Management National Chung Hsing University.
ACM Programming Contests
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
Methods (Functions) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
ACM Programming Contests Coordinator: Dr. Hubert Chan Coach: Luyi Mo Training Holder: Jonathan So Website: i.cs.hku.hk/~provinci.
General Programming Introduction to Computing Science and Programming I.
Introduction. 2COMPSCI Computer Science Fundamentals.
Fundamentals of Algorithms MCS - 2 Lecture # 1
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
Loops: Handling Infinite Processes CS 21a: Introduction to Computing I First Semester,
Lecture 1: Introduction and Overview CSCI 700 – Algorithms 1.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Overview Algorithms Baojian Hua
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
ACM programming contest Introduction + Recursion.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
ACM programming contest Introduction. ACM International Collegiate Programming Contest (a.k.a. ACM ICPC, ACM competition, ICPC) is the largest university-level.
The SECOND Meeting Or: How I learned exciting new things in CS Club.
The while-statement. Syntax and meaning of the while-statement The LOOP-CONTINUATION-CONDITION is a Boolean expression (exactly the same as in the condition.
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
The Hashemite University Computer Engineering Department
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Simple algorithms on an array - compute sum and min.
Fundamental Programming Fundamental Programming Introduction to Functions.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
Tisigram 2016 Technical Meeting Tuesday, March 28 th, 2016.
Computer Science 210 Computer Organization
Chapter 2 - Introduction to C Programming
Richard P. Simpson Midwestern State University
Chapter 2 - Introduction to C Programming
Building Java Programs
Computer Science 210 Computer Organization
Some Basics for Problem Analysis and Solutions
Software John Sum Institute of Technology Management
Introduction to Algorithms
Examples Example Problems, their Algorithms, and their C Source Code.
Week 4 Lecture-2 Chapter 6 (Methods).
Introduction to C Programming
Introduction to Computing Lecture 08: Functions (Part I)
Incremental Programming
The while Looping Structure
CHAPTER 6 Testing and Debugging.
Advanced Analysis of Algorithms
Presentation transcript:

Getting familiar with ACM Contest

What is ACM ACM: Association for Computing Machinery o o the world’s largest educational and scientific computing society ACM ICPC o ACM International Collegiate Programming Contest o

ACM ICPC ICPC is a competition among teams of students representing institutions of higher education. o Teams compete in Regional Contests, from which top scoring teams advance to the ACM-ICPC World Finals. Each team has three students, sharing one computer, given a number of programming problems o Coordination and teamwork are essential

ACM finals 2014 Hosted by Ural Federal University, Ekaterinburg, Russia

ACM finals 2014 winners St.Petersburg State University Team 7 problems solved / 12 problems Cup + prizes + a work placement and a job offers from IBM and other companies

Programming Languages and Judge You can use: o C, C++, Java and others such as: Python, C# Online Judge o Feedback : Accepted (AC) – congratulations! Presentation Error (PE) – Your program outputs are correct, but are not presented in the specified format. Check for spaces, left/right justification, line feeds, etc. Wrong Answer (WA) – Your program returned an incorrect answer to one or more of the judge’s secret test cases Compile Error (CE) – The judge’s compiler cannot compile your source code Runtime Error (RE) – Your program failed during execution due to a segmentation fault, floating point exception, or others. Time Limit Exceeded (TL) – Your program took too much time on at least one of the test cases. Try to improve the efficiency of your solution! Memory Limit Exceeded (ML) – Your program tried to use more memory than the judge’s settings.

Available Online Judges Famous online judges o Valladolid OJ ( o Ural OJ ( o Saratov OJ ( o ZJU OJ ( o ZJUT OJ ( o Official ACM Live Archive ( o Peking University Online Judge ( o Programming Challenges (

To get ready some suggested Books Art of Programming Contest (free online) o judge.uva.es/p/Art_of_Programming_Contest_SE_for_uva.pdf judge.uva.es/p/Art_of_Programming_Contest_SE_for_uva.pdf Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to Algorithms, 2nd Edition, The MIT Press, Robert Sedgewick, Bundle of Algorithms in Java, Third Edition (Parts 1-5), 3rd Edition, Addison-Wesley Professional, (There is also a C++ version). Donald E. Knuth,The Art of Computer Programming, Volume 1, 2, 3.

Subjects You should be familiar with: o Data Structure o Strings and Sorting o High precision arithmetic o Combinatorics and number theory o Divide and conquer & backtracking o Dynamic programming o Computational geometry o Scientific computing

Standard in ACM contest Input/Output o each program must read the test data from the standard input and print the results to the standard output For C language, use scanf() and printf() For C++, use cin and cout o scanf() and printf() are also supported For Java, refer to challenges.com/pg.php?page=javainfohttp:// challenges.com/pg.php?page=javainfo o Programs are not allowed to open files or to execute certain system calls

Not nice for debugging #include int main () { freopen(“FILE_NAME_FOR_INPUT”,”r”,stdin); freopen(“FILE_NAME_FOR OUTPUT”,”w”,stdout); Rest of the codes… return 0; } While sending your code to online judges, remember to remove the two lines with freopen.

Things to avoid Avoid the usage of the ++ or -- operators inside expressions or function calls Avoid expressions of the form *p++ Avoid pointer arithmetic. Instead of (p+5) use p[5]. Never code like : return (x*y)+Func(t)/(1-s); o but like : temp = func(t); RetVal = (x*y) + temp/(1-s); return RetVal;

Things to avoid Naming o Don’t use small and similar names for your variables. Use descriptive names. o Don’t use names like {i,j,k} for loop control variables. Use {I,K,M}. o It is very easy to mistake a j for an i when you read code or “copy, paste & change” code,

Nature of problems to solve Data structure problems Algorithms o To solve real problems efficiently Categories: o Sorting o Searching o Graph algorithms o Scientific computing: matrix, number-theoretic, computational geometry, etc. -etc Mathematics o Everything finally goes back to mathematics! o Number theory o Geometry o Combinatorics o Graph theory o …

Good Team Knowing your strength and weaknesses Knowledge of standard algorithms and the ability to find an appropriate algorithm for every problem in the set; Ability to code an algorithm into a working program; Having a strategy of cooperation with your teammates

Tips & tricks Brute force when you can, Brute force algorithm tends to be the easiest to implement. KISS: Simple is smart! (Keep It Simple, Stupid !!! / Keep It Short & Simple). Hint: focus on limits (specified in problem statement). Waste memory when it makes your life easier (trade memory space for speed). Don't delete your extra debugging output, comment it out. Optimize progressively, and only as much as needed. Keep all working versions!

Tips & tricks Code to debug: o a. white space is good, o b. use meaningful variable names, o c. don't reuse variables, (we are not doing software engineering here) o d. stepwise refinement, o e. Comment before code. Avoid pointers if you can. Avoid dynamic memory like the plague: statically allocate everything. Try not to use floating point; if you have to, put tolerances in everywhere (never test equality)

Problem example Source: Time Limit:1 second Memory Limit:32768 KB Description: Calculate a + b Input: o The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line. Output: o For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample Input: 1 5 Sample Output: 6

Solution /* C code */ #include “stdio.h” int main() { int a, b; while (scanf(“%d %d”, &a, &b) != EOF) { printf(“%d\n”, a+b); } return 0; } /* Java code */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int a = in.nextInt(); int b = in.nextInt(); System.out.println(a + b); }

Set of problems that you can train on Source: Fundamental Problems Source: Fundamental Problems