Introduction to programming competition
-
Upload
yak1ex -
Category
Technology
-
view
2.442 -
download
3
description
Transcript of Introduction to programming competition
![Page 1: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/1.jpg)
はじめての競技プログラミングOSC 名古屋 2011 8/20 (土)
@yak_ex / 新 康孝 (CSNagoya)@rofi
![Page 2: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/2.jpg)
発表の流れ
前半 (45 分 ) :競技プログラミング / サイトの紹介(@yak_ex) 競技プログラミングとは 競技プログラミングサイト紹介(含む実演)
後半 (45 分 ) :問題 / アルゴリズム解説+ α(@rofi) 基本的なデータ構造 実際の問題に合わせてアルゴリズム解説 競技プログラミングから見た C++0x (@yak_ex)
![Page 3: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/3.jpg)
自己紹介
氏名: 新 康孝 ( あたらし やすたか ) Twitter ID: yak_ex Web: http://yak3.myhome.cx:8080/junks
C++ / Perl が主戦場 仕事でコードに触れていないので
競技プログラミングで潤い補充TopCoder 1577 / Codeforces 1762
学生時代に ACM/ICPC 出場、 1 年くらい前に競技プログラミングに復帰
![Page 4: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/4.jpg)
オープンソースと競技プログラミング オープンソース
世界中の開発者のコードが見られる 世界中に潜在的利用者が居る
競技プログラミング 世界中の参加者のコードが見られる 世界中の参加者と腕を競える
もっと被って良さそげなのにいまいちオープンソース界と競技プログラミング界があまり被ってなさそげ → 布教
![Page 5: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/5.jpg)
競技プログラミングとは
制限された時間内に与えられた問題を解くためのプログラムを作成、その速さと正確性を競う知的スポーツ
「プログラミングコンテスト」で思い浮かべるテーマに合わせたソフトを応募、審査するコンクール形式とは違って機械的に勝ち負けを判定可能
![Page 6: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/6.jpg)
問題の例 ある東西に伸びたものすごく長い道路にホットドッ
グ屋がたくさんいます。各ホットドッグ屋は東西 1 m/s で移動できます。初期状態が与えられている時に、どのホットドッグ屋間も最低 D m 離れている状態になるまで最低何秒かかるでしょうか?(Google Code Jam 2011 Round1B 抄訳 )
1m/s
D m最低何秒かかるか?
![Page 7: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/7.jpg)
問題の例入力例23 20 13 26 12 20 31 1
1m/s
D m最低何秒かかるか?
出力例Case #1: 1.0
Case #2: 2.5
← テストケース数 T← 位置の数 C 距離 D← 位置 P ホットドッグ屋数 V
C 回繰り返し
T 回繰り返し1 ≤ T ≤ 50
-10 P 10 ≦ ≦ :整数V :正の整数1 D 10 ≦ ≦ : 整数1 C 200 ≦ ≦ : 整数ホットドッグ屋数≦ 10
5 5
6
6 b.cpp
解答例
← 問題文にある条件
![Page 8: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/8.jpg)
なぜ競技プログラミング?
白黒はっきりするので目標にしやすい コード自体は複雑にならないので、入門書を終えて次
に何やっていいか分からない人に最適? 計算量(時間/空間)の感覚が身につく デバッグ力があがる 他人のソースコードを読む力が付く テストケースを考えられる(コーナーケースが
考えられるようになる)何より楽しい
![Page 9: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/9.jpg)
主な競技プログラミング大会 / サイト TopCoder ○ Codeforces ○ Google Code Jam ○ AOJ (会津大学オンラインジャッジ) ACM/ICPC ( ACM 国際大学対抗プログラミン
グコンテスト)
○ が付いているサイトについて(練習モードで)実演
![Page 10: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/10.jpg)
TopCoder http://community.topcoder.com/tc 競技プログラミングと言えばまずはここ コンテストは複数種開催されているが競技プログラミングとしては SR
M(Short Round Match) が基本。月 3 回程度。 レーティング有り。 Div1 (1200 以上 ) / Div2 に分かれていて問題が違う
形式 3問 95 分 / 問題によって最大得点が異なる典型的には 250, 500, 1000時間に応じて得られる得点が減少していくCoding 75 分→休憩 5 分→ Challenge 15 分2 秒、 64MB 制限正誤判定(システムテスト)は競技時間終了後
システム Java 使用による独自 UI
使用可能言語 C/C++, C#, Java, VB
参加者数 アクティブ: 8,600 人 1SRM 2,000 人強制限
![Page 11: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/11.jpg)
Codeforces http://www.codeforces.com/ 比較的最近できたロシアの競技プログラミングサイト。月 4 回くらい。
以前はよく落ちたりしていたが最近はシステムは安定している 英語が読みにくいと言われることが多い
Gmail 、 OpenID でログイン可能 レーティング有り。 Div1 (1650 以上 ) / Div2 があるが一括開催だった
り片方のみ開催だったり色々
形式 5 問 120 分 / 最大得点が異なり時間に応じて減少
Challenge に相当する Hack が可能だが時間枠が分かれていない
実行時間、メモリ制約は問題毎に明示正誤判定(システムテスト)は競技時間終了後
システム Web (Web2.0 による競技 PG サイトを標榜 )
使用可能言語 Pascal, C, C++, C++0x, C#, Java, PHP, Python, Ruby, Haskell
参加者数 7,900 人 1Round 1,500 人強
![Page 12: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/12.jpg)
Google Code Jam http://code.google.com/codejam/ Google が開催している年に 1 度のお祭り 決勝はオンサイトでやる
形式 勝ち抜き制 予選+ 4 回くらい?予選は 24 時間 各問題に対し、データ量等が少ない small input と 多い
large input がある 提出に時間制限あり( small 4 分 / large 8 分) 問題、 small or large で得点が異なる small input は即結果判定有りで、時間中に複数回提出可能 large input は一発勝負で結果は競技時間終了後判明 得点と、正答累積時間+ 4 分 × (正答迄の)誤答数で順位
付けシステム Web (ローカルで実行した結果を提出)使用可能言語 自由参加者数 13,000 人 (2011 予選提出者 )
![Page 13: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/13.jpg)
AOJ( 会津大学オンラインジャッジ )
http://judge.u-aizu.ac.jp/onlinejudge/ 日本にあるオンラインジャッジ
オンラインジャッジ:用意された過去問等に対してソースを送信すると自動で正誤を判定してくれるサイト
黙々と練習するのに良い
システム Web
使用可能言語 C, C++, Java
参加者数 3,700 人
![Page 14: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/14.jpg)
ACM/ICPC(ACM国際大学対抗プログラミングコンテスト ) http://cm.baylor.edu/welcome.icpc http://icpc2011.ait.kyushu-u.ac.jp/ja/home ACM( アメリカ計算機学会 ) 主催のプログラミングコンテスト 大学生対象 チーム制で 1チーム 3 人、 1PC共用 基本オンサイト
形式 国内予選→アジア予選→決勝4,5 時間 7~ 10 問程度正答数と、正答累積時間+ 20 分 ×( 正答迄の ) 誤答
数で順位付け電子的な事前準備禁止
システム 国内予選は Web
使用可能言語 C, C++, Java
参加者数 88 カ国、 2,070 大学、 8,305チーム (2010)
![Page 15: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/15.jpg)
実演
TopCoder アカウント登録 SRM 登録 SRM( 今回は Practice)
Codeforces Round 登録 Round( 今回は Practice)
Google Code Jam Practice
![Page 16: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/16.jpg)
TopCoder 実演
アカウント登録 http://community.topcoder.com/tc Register Now→on TopCoder→ 頑張って入力→メール受信→ URL
ref. http://mainly-coding.blogspot.com/2010/02/topcoder.html SRM 登録 (SRM 開始 3 時間前から )
(Java 実行環境インストール ) http://community.topcoder.com/tc Competitions→Algorithm→Single Round Matches (SRM)→Launch
Arena Active Contests→ どれか→ Register
SRM Launch Arena まで↑と一緒 実際には Active Contests → Enter Practice は Practice Rooms→SRMs→ どれか Challenge は Summary からダブルクリック Practice での System Test は Practice Options → Run System Te
st
![Page 17: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/17.jpg)
Codeforces 実演
設定 http://www.codeforces.com/contests 右上の Enter からログイン Settings → Social の Country に入れておくと国別ランキングに集
計 ※CF / TC 日本参加者比較表
http://yak2.myhome.cx/misc/cfjp.html Round登録 (Round 開始 24 時間前から )
ログインまで↑と同じ Register
Round ログインまで↑と同じ Enter ( 実際には時間になると勝手に Enter 伺いが出る ) Practice は 適当な Round の Enter → Register for Practice Hack は Room からセルをダブルクリック (Practice 不可 ) Hack するためには Lock が必要 Hack されても Lock していなければ再提出が可能
![Page 18: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/18.jpg)
Codeforces の問題状態遷移
PretestPassed
PretestFailed
初期状態
Hacked
System
Test
の壁
Passed System Test
Locked
Failed System Test
After lockhacked
再提出成功
ハックされる
提出成功
提出失敗再提出
成功
システムテスト通過
システムテスト通過ならず
ロック
ハックされる
![Page 19: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/19.jpg)
Google Code Jam 実演
事前登録 http://code.google.com/codejam/ 実際には Practice のところで登録が必要
Practice Input ファイルをダウンロードして実行、出力を提
出 CUI ツールもできたが未使用なので説明できない 実際には時間制限あり Short input はリトライ可能、 Large input はリト
ライ不可
![Page 20: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/20.jpg)
書籍・コミュニティ プログラミングコンテストチャレンジブック
通称:蟻本ISBN978-4-8399-3199-5 \3,280+ 税秋葉拓哉 (@iwiwi) ・岩田陽一 (@wata_orz) ・北川宜稔 (@kita_masa)
TopCoder 部http://topcoder.g.hatena.ne.jp/
Twitter今すぐフォローすべき競技プログラミング界のスーパーエンジニアhttp://d.hatena.ne.jp/chokudai/20110617/1308242031
ニコニコ生放送LayCurse(@laycrs) 、診断人 (@nico_shindannin)
![Page 21: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/21.jpg)
用語集用語 原語 意味Red Coder レーティングが赤い人。殿上人。Editorial 出題者による問題の解説AC ACcepted 正解WA Wrong Answer 誤答RE Runtime Error 実行時エラーPE Presentation Error 出力形式エラーTLE Time Limit Exceeded 実行時間超過MLE Memory Limit Exceeded メモリ制限超過GL & HF Good Luck & Have Fun チャット等で良くある挨拶DFS Depth-first search 深さ優先探索BFS Breadth-first search 幅優先探索DP Dynamic Programming チャット等で良くある挨拶
![Page 22: Introduction to programming competition](https://reader035.fdocuments.net/reader035/viewer/2022062514/558297c5d8b42a94688b4741/html5/thumbnails/22.jpg)
ご清聴ありがとうございました。