1. ACMACMACMACMACMACMACMA
CMACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
ACM Training Session
MACMACMACMACMACMACMAC
BRAC UNIVERSITY
MACMACMACMACMACMACMAC 2/11/2012
Raduan & Mahbub
MACMACMACMACMACMACMAC
This work is licensed under a Creative Commons Attribution-
MACMACMACMACMACMACMAC
NonCommercial-ShareAlike 3.0 Unported License.
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
MACMACMACMACMACMACMAC
2. Page 1 of 6
Association of Computing Machinery (ACM)
How to Start
1. Online judge like UVA, TJU, HDU, Top Coder (TC) etc [Register]
2. Try the simpler one then step by step (USACO)
3. Learn Data Structures (Built in) [in some case you have to implement your own Data Structure]
4. Learn Algorithms (read books, watch video on YouTube etc)
5. Participate in Programming Contest
6. First do it on paper then start coding (think just don’t jump on the problem)
7. Keep it Simple (KIS)
8. If not getting AC try another one don’t waste time
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)
3. Page 2 of 6
Contest Basic Terms
1. AC = Accepted (No error :-))
2. WA = Wrong Answer (Spelling Problem, Wrong Algorithm, Over-flow, Missing Corner Cases,
Misread, Lexicographical answer)
3. RE = Run Time Error (Array Index Out of Bound, Dividing by zero etc.)
4. TLE = Time Limit Exceed (Weak Algorithm, Infinity Loop)
5. MLE = Memory Limit Exceed (Defining 2DArray of Size>1000)
6. PE = Presentation Error (Spacing Problem)
7. CE = Compile Error (Using variables without defining)
Common Errors
1. Overflow
2. Run Time Error
3. 0-1 indexing
4. For floating calculation remember the following things
[Integer division][Yields wa]
= 1.5714285714285714 [ ]
Types of Problems
1. Adhoc
2. Graph
3. Geometry
4. Number Theory
5. Numerical Methods
6. Dynamic Programming
7. Greedy
8. String Matching
9. Sorting and Searching
10. Combinatorics
11. etc
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)
4. Page 3 of 6
Algorithms: (Only discussion topic)
Data Structures: 2D array, Recursion
String: Input Parsing, String Tokenizer.
Number Theory: GCD, LCM, Prime Check, Pre-Generating Prime (Sieve), Number of Divisors, Sum
of Divisor etc.
Geometry: Using mathematical built in function, Equality checking for double, in circle, Ex-circle,
Area of Polygon, Points in (Rectangle, Circle, and Triangle)
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)
5. Page 4 of 6
Types of input in JAVA for ACM
Scanner sc = new Scanner (System.in);
/* Blank line Style input
12
String line;
3
while(true) {
34
line = sc.nextLine ();
323
if(line.equals(""))
<Blank line>
break;
*/
4
/* TEST CASE Style input BRAC
int T = sc.nextInt(); PRANGON
while(T-- > 0) {
CAFE
}
CSE
*/
BRAC
/* EOF Style input
while(hasNextLine()) { PRANGON
} CAFE
*/ CSE
EOF
/* Sentinel Style input
int SENTINEL = -1; BRAC
while(true) {
PRANGON
int n = sc.nextInt();
CAFE
if(n == SENTINEL)
CSE
break;
-1
}
*/
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)
6. Page 5 of 6
Books
1. Art of programming contest by Ahmed Shamsul Arefin.
2. How to solve it by Computers by R.G.Dromey
3. Java How to Program
4. Competitive Programming 2: This increases the lower bound of Programming Contests. Again by
Steven Halim and Felix Halim [http://uhunt.felix-halim.net/id/339]
Links of Online Judge
1. http://acm.tju.edu.cn/toj/
2. http://uva.onlinejudge.org/
3. http://ace.delos.com/usacogate
4. http://www.topcoder.com/
5. http://www.spoj.pl/
6. http://www.codechef.com/
7. http://campion.edu.ro/arhiva/
8. http://acm.fzu.edu.cn/index.php
9. http://acm.hit.edu.cn/index.php
10. http://infoarena.ro/
11. http://acm.lviv.ua/fusion/news.php
12. http://acm.mipt.ru/judge/login.pl?lang=en
13. http://acm.pku.edu.cn/JudgeOnline/
14. http://acm.sgu.ru/
15. http://acm.timus.ru/
16. http://acm.zju.edu.cn/onlinejudge/
17. http://acm.hdu.edu.cn/
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)
7. Page 6 of 6
A "Theorem": All odd numbers is a prime
Taken from Prof Leong Hong Wai joke during CS1305 lecture.
Mathematician:
3 prime, 5 prime, 7 prime, 9 not prime... aha!!! Therefore this theorem is false.
Physicist:
3 prime, 5 prime, 7 prime, 9 OOPS experimental error, ignore this, 11 prime, 13 prime, this theorem
is true
Engineer:
3 prime, 5 prime, 7 prime, 9 prime, 11 prime, 13 prime, hmm.. nothing wrong here, this theorem is
true.
Computer Scientist:
3 prime, 5 prime, 7 prime, 7 prime, 7 prime, 7 prime, 7 prime, 7 prime (Infinite loop :-).
Raduanul Islam (10101024) & S. Mahbub – Uz – Zaman (09301004)