快樂營- 1
&
問題ディスカッション
競賽と演算法導入 &
問題ディスカッション
momohuang August 6, 2013
1 Introduction to Algorithm Competitions
Introduction
1. : 2. 1.
: 2. 1.
2. 1. 樂 : 2.
1. 2. XD
( )
:)
I
1.1 Main Ops
&
問題ディスカッション
1.1 Main Ops
9 12
11 10
12 10 TOI
3 TOI
3 TOI 營 100 20
4 TOI 30 12
5 TOI 12 4
7 IOI 2014
1.2 Side Ops
11 10
11∼ NPSC
12 PK
USB
1.3 Black Ops : Online Contests
codeforces.com
usaco.org 11
快樂
codechef.com
topcoder.com
II
1.4 Shooting Range : Online Judges
&
問題ディスカッション
1.4 Shooting Range : Online Judges
SGU acm.sgu.ru OJ
POI main.edu.pl/en OJ
URAL acm.timus.ru OJ
POJ poj.org
TIOJ 218.210.35.237:8080/JudgeOnline tmt514 OJ
HOJ hoj.twbbs.org/judge/ hanhan0912
OJ xD
1.5 Arms Supply : Massive Online Open Courses
• Coursera MOOC Stanford Andrew Ng
CS
• edX MIT Harvard MOOC CS
• Udacity
• SAO VRMMO
1.6 With Knowledge, Comes Power
•
•
• project –in a daze- タ
(ps. power )
( P)
III
2. What Exactly Is Algorithm ?
&
問題ディスカッション
2 What Exactly Is Algorithm ?
快樂 營
問 問
問
A, B (0< A, B≤300000000) A+B
C/C++ + A+B
1 Algorithm 1
1: int A, B, answer = 0, i;
2: input(A, B);
3: for(i = 0; i < A; i++) answer ++;
4: for(i = 0; i < B; i++) answer ++;
5: output(answer);
stdio
XD
A, B, answer, i 4byte
IOI 16byte
16∼256MB 問
10byte
1+ 1+A+A+A+ 1+B+B+B = 3×(A+B+1)
1 109 A B 300000000
1
IV
2. What Exactly Is Algorithm ?
&
問題ディスカッション
A B
O 3A+ 3B + 3 O O(3A+ 3B+ 3) = A+B
1 for A+B Big-O
Θ Ω
O(100) = 1
O(N2+ 10×N + 11) =N2
O(N3×2N +N2+ 13) =N3×2N O(A+B+ 10×A×B+ 28) =A×B
Big-O
Big-O 20∼100
code 100
109
問 快
109
70%
5ms 50000$
1 XX
2 問 1 2 2 A+B
XD
V
3. The Martial Arts of Problem Solving
&
問題ディスカッション
3 The Martial Arts of Problem Solving
問 mo n 問 mo n da i mo n su ta 問
スター 問
遭遇到一
問スター WIN LOSE
WIN
WIN
WIN LOSE
LOSE
if for
VI
4. Some 問スターCorpses
&
問題ディスカッション
4 Some 問スター Corpses
1. <SGU 107> 987654321 スター
N ≤ 106 987654321
2. <SGU 126> スター
1 A 2 B A+B <
2147483648 1
2 2
-1 3. <TIOJ 1330> スター
N(N(N ...))}N
2 (N <1000)
4. <no judge pure thinking> スター
問 A= 3 (3(3...))}n B = 9 (9(9...))}m
m n A B (n, m≤106)
5. <no judge pure thinking> スター
N A
B PK
lose
問 N, A, B ≤1000
6. <no judge pure thinking> スター
樂
7. <SGU 105> スター
1,12,123,1234, . . . ,12345678910, . . .
問 N N ≤2147483647
8. <no judge pure thinking> スター
A+B A B
問 VII
4. Some 問スターCorpses
&
問題ディスカッション
9. <POI18 Party> スター
3n 2n
n n
high n n ≤1000
10. <Codeforces 277B> スター
N N
M 快
N ≤100, M ≤N ≤2M 11. <Codeforces 197A> スター
A B R
A, B, R≤100
12. <Codeforces 297A> スター
01 A B
A A 1000 → 10001 1001 → 10010
A 問 A B A, B ≤1000
13. <Codechef CHALENGE> スター N 8∼12
hash
T
(250 ≤T ≤2000,50≤N ≤200,max(N −50,N2)≤H ≤N −10)
VIII