<style> .orange { color: orange; } .green { color: green; } .red { color: red; } section.present > div > pre > code { max-height: 700px; max-width: 2000px; font-size: 16px; } h2 > span { font-size: 60px; color: #ff88ff; } h3 > span { font-size: 60px; color: #ee4400; } h4 > span { font-size: 27px; color: orange; } .example-table { width: 100%; font-size: 20px; } .example-table td { height: 100px; width: 500px; } .example-table figure { position: relative; height: 150px; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; } .example-table img { height: 100px; margin: 0; top: 0; background: transparent; } .example-table figcaption { text-align: center; font-size: 27px; width: 100%; bottom: 0; } </style> $$ \begin{array}{c} \texttt{C++ Competitive Programming Course}\\ \textbf{Introduction to Competitive Programming}\\ \end{array} $$ <table style="font-size: 27px;"> <tr> <td class="green"><strong>Lecturer:</strong></td> <td class="orange">Võ Hoàng Anh</td> <td class="green"><strong>Course:</strong></td> <td class="orange">CODEMELY</td> </tr> <tr> <td class="green"><strong>Nickname:</strong></td> <td class="orange">@SPyofgame</td> <td class="green"><strong>Semester:</strong></td> <td class="orange">2024-2025</td> </tr> <tr> <td class="green"><strong>Assistant:</strong></td> <td class="orange"></td> <td class="green"><strong>Session:</strong></td> <td class="orange">#1</td> </tr> </table> <table style="font-size: 20px;"> <tr> <td colspan="4" class="red"><strong>Course Info:</strong> </td> <td> <a href="https://hackmd.io/@codemely/index">https://hackmd.io/@codemely/index</a></td> </tr> <tr> <td colspan="4" class="red"><strong>Read as note:</strong> </td> <td> <a href="https://hackmd.io/@codemely/introduction">https://hackmd.io/@codemely/introduction</a></td> </tr> <tr> <td colspan="4" class="red"><strong>Read as slide:</strong> </td> <td> <a href="https://hackmd.io/@codemely/slide1">https://hackmd.io/@codemely/slide1</a></td> </tr> <tr> <td colspan="4" class="red"><strong>Hashed link:</strong> </td> <td> <a href="https://hackmd.io/ICik8f6FTmWz5qBxSihNlg?view#/">https://hackmd.io/ICik8f6FTmWz5qBxSihNlg?view#/</a></td> </tr> </table> --- ## I. Lecturer First Meeting <div style="display: flex; justify-content: center;"> <figure style="margin-right: 50px; text-align: center;"> <img src="https://hackmd.io/_uploads/Hk6FzTtBR.png" alt="" style="height:100px; max-width:100px"> <figcaption>Lecturer SPyogame</figcaption> </figure> <figure style="margin-right: 50px; text-align: center;"> <img src="https://hackmd.io/_uploads/rylZ7VELC.png" alt="" style="height:100px; max-width:100px"> <figcaption>CodeMely Members</figcaption> </figure> </div> --- ### I.1 - Who is SPyofgame ? <div style="display: flex; justify-content: center;"> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/HJrlXUZL0.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2016</figcaption> </figure> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/H1bYDaYHR.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2017</figcaption> </figure> <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/r1kkUTtr0.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2018</figcaption> </figure> </div> <div style="display: flex; justify-content: center;"> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/S1sELpKHC.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2019</figcaption> </figure> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/ry4P_aKSR.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2020</figcaption> </figure> <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/B1IfSTtHC.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2021</figcaption> </figure> </div> <div style="display: flex; justify-content: center;"> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/B1sCL6tHA.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2022</figcaption> </figure> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/BJPjEaKSA.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2023</figcaption> </figure> <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJ9uLpKrC.png" alt="" style="height:100px; max-width:100px"> <figcaption>Year 2024</figcaption> </figure> </div> ---- ### I.1 - Who is SPyofgame ? #### I.1-a) Year 2016 - Tan Loi H.S., Grade 6 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/ByAO_pFH0.png" alt="" style="height: 250px;height:300px;"> </figure> </center> My journey started when I was in Grade 6. I enjoyed IT but I didn't know English. I was able to type 80 wpm at that time. ---- ### I.1 - Who is SPyofgame ? #### I.1-b) Year 2017 - Tan Loi H.S., Grade 7 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/H1bYDaYHR.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I started to use `Scratch` in Grade 7. I learned English and coding on my own. My first released game had 200 plays per week. ---- ### I.1 - Who is SPyofgame ? #### I.1-c) Year 2018 - Tan Loi H.S., Grade 8 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/r1kkUTtr0.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I started to learn `Pascal` in grade 8. I was one of four selected for the OI Contest. I failed the provincial round miserably ! ---- ### I.1 - Who is SPyofgame ? #### I.1-d) Year 2019 - Tan Loi H.S., Grade 9 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/S1sELpKHC.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I started to learn `C++` in Grade 9. I still tried my best to excel in the provincial contest. I failed to advance to the next round by `0.01` points. ---- ### I.1 - Who is SPyofgame ? #### I.1-e) Year 2020 - Nguyen Du HSGS, Grade 10 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/B1IfSTtHC.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I got into HSGS with a `0.001` margin I failed the provincial contest miserably. I started learning algorithms on Codeforces. ---- ### I.1 - Who is SPyofgame ? #### I.1-f) Year 2021 - Nguyen Du HSGS, Grade 11 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/ry4P_aKSR.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I skipped classes just to learn coding. I was on the FFA chess leaderboard on `chess.com`. I got into the National Team but failed VOI miserably. ---- ### I.1 - Who is SPyofgame ? #### I.1-g) Year 2022 - Nguyen Du HSGS, Grade 12 <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/B1sCL6tHA.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I grinded my health for coding with sleepless nights. I joined `300+` contests with `3000+` solved problems. I failed VOI but got a consolation prize as a top ranker. I earned my first paycheck as a Codeforces setter. ---- ### I.1 - Who is SPyofgame ? #### I.1-h) Year 2023 - HCMUS, 1st Year Student <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/BJPjEaKSA.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I created `200+` editorials and `20+` problems. I won an Amateur National OI championship. I won third prize for National ICPC. ---- ### I.1 - Who is SPyofgame ? #### I.1-i) Year 2024 - HCMUS, 2nd Year Student <center> <figure style="margin-right: 100px; text-align: center;"> <img src="https://hackmd.io/_uploads/HJ9uLpKrC.png" alt="" style="height: 250px;height:300px;"> </figure> </center> I taught students for free for `69` 3-hour sessions. My first fivethree students were admitted to HSGS. I created my first `C++` game of `16000` lines of code. --- ### I.2 - Introduce yourself <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/rylZ7VELC.png" alt="" style="height: 250px;height:300px;"> <figcaption>CodeMely Members</figcaption> </figure> ---- ### I.2 - Introduce yourself #### I.2-a) What is your target ? <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJQFNRtBA.png" alt="" style="height: 250px;height:300px;"> <figcaption> "Aim to write not just code, but the future itself" </figcaption> </figure> ---- ### I.2 - Introduce yourself #### I.2-b) Why do you want to learn ? <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/ryGMHRKBC.png" alt="" style="height: 250px;height:300px;"> <figcaption> "Knowledge is power, with time as currency" </figcaption> </figure> ---- ### I.2 - Introduce yourself #### I.2-c) How do you self-learn ? <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/S1C64CYrC.png" alt="" style="height: 250px;height:300px;"> <figcaption>"Shape yourself, reshape the whole world"</figcaption> </figure> --- ### I.3 - What do you gains from coding ? <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/BJUAD0tH0.png" alt="" style="height: 250px;height:300px;"> <figcaption>Coding is real-life magic</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-a) Time Control <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HyeFFCFHC.png" alt="" style="height: 250px;height:300px;"> <figcaption>You have flexible time schedule</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-b) Free Money++ <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/SJ40qRFS0.png" alt="" style="height: 250px;height:300px;"> <figcaption>Better career, easier money gain</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-c) Human Manipulation <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/S1yMoCKSC.png" alt="" style="height: 250px;height:300px;"> <figcaption>You have better people, know more opportunities</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-d) X-Ray Eyes <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJWFhCtSA.png" alt="" style="height: 250px;height:300px;"> <figcaption>You can decise better and avoid risks</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-e) Super Abilities <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/r1eN6CYrC.png" alt="" style="height: 250px;height:300px;"> <figcaption>Problem Solving Skills and Analytical Thimking</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-f) Dominace Power <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/rJEqaCYrR.png" alt="" style="height: 250px;height:300px;"> <figcaption>Your words are strong, you have influence</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-g) Quick Teleportation <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/S17N0RtB0.png" alt="" style="height: 250px;height:300px;"> <figcaption>You are funded to travel many places</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-h) Build Harem <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJfs0AYrR.png" alt="" style="height: 250px;height:300px;"> <figcaption>You have collaborations from everywhere</figcaption> </figure> ---- ### I.3 - What do you gains from coding ? #### I.3-i) Infinity Stones <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/SJg0CRtSR.png" alt="" style="height: 250px;height:300px;"> <figcaption>The learning resources are scattered everywhere</figcaption> </figure> --- ### I.4 - Coding Philosophy <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/BkIVF0FHR.png" alt="" style="height: 250px;height:300px;"> <figcaption>50% of your success based on your first step</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-a) Take Damn Steps <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/S1Sy90trA.png" alt="" style="height: 250px;height:300px;"> <figcaption>Take your damn first steps, yes, literally !</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-b) Your Inevitable Sacrifice <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/BJzCdAtH0.png" alt="" style="height: 250px;height:300px;"> <figcaption>Get out of your safe zone: gaming/tiktok/facebook</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-c) Stop Wasting Yourtime <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/SJAZuRtrR.png" alt="" style="height: 250px;height:300px;"> <figcaption>Focus on what you need !</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-d) Code everywhere anytime <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/B19j1y9SC.png" alt="" style="height: 250px;height:300px;"> <figcaption>If you can learn something good, learn !</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-e) Stop Excuse Yourself <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/S1W0yy9H0.png" alt="" style="height: 250px;height:300px;"> <figcaption>If you want something, try your best to do it !</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-f) Talk Less, Code ! <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/r1Oqx1qSC.png" alt="" style="height: 250px;height:300px;"> <figcaption>No one cares how you tried, but what you succeeded</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-g) Dont f\*ckin' cheat ! <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/By_WWJcSR.png" alt="" style="height: 250px;height:300px;"> <figcaption>Cheating often backfires when you least expect it.</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-h) Nothing to lose <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/Hyn4NJcrA.png" alt="" style="height: 250px;height:300px;"> <figcaption>Experts fails more than you ever try</figcaption> </figure> ---- ### I.4 - Coding Philosophy #### I.4-i) Rise Above All <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/rJR6rJ9S0.png" alt="" style="height: 250px;height:300px;"> <figcaption>Master your skills, only helpless beg for luck</figcaption> </figure> --- ### I.5 - Where to begin ? ![image](https://hackmd.io/_uploads/rkmc-TYSC.png) ---- ### I.5 - Where to begin ? #### I.5-a) Online Compiler <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/Bk2bwJcHC.png" alt=""> <figcaption>Ideone</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/S13fOy5H0.png" alt=""> <figcaption>OneCompiler</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BkKMv1qrA.png" alt=""> <figcaption>OnlineGDB</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/Sy5FPwcS0.png" alt=""> <figcaption>Replit</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SkTaHPqSA.png" alt=""> <figcaption>CodeInterview</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJuwoJqHC.png" alt=""> <figcaption>Codeforces</figcaption> </figure> </td> </tr> <tr> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-b) Offline Compiler <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SySVo1cHA.png" alt=""> <figcaption>VScode</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rkPpdJ5BC.png" alt=""> <figcaption>MSVC</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/ryvhd19rC.png" alt=""> <figcaption>Codeblock</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/HJmJK15BC.png" alt=""> <figcaption>DevC++</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BkMEYk9rR.png" alt=""> <figcaption>SublimeText</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BJIPtJ5HC.png" alt=""> <figcaption>Notepad++</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SyVosPqrC.png" alt=""> <figcaption>Nano</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rkMC5y5rC.png" alt=""> <figcaption>Vim</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/H1unFkqSA.png" alt=""> <figcaption>Notepad</figcaption> </figure> </td> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-c) Online Judge <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SJQcnJ9HC.png" alt=""> <figcaption>Atcoder</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SypoTk5H0.png" alt=""> <figcaption>HackerRank</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SkExny9BA.png" alt=""> <figcaption>Leetcode</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJuwoJqHC.png" alt=""> <figcaption>Codeforces</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/BkZYsy5B0.png" alt=""> <figcaption>SPOJ</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJOAi1cSA.png" alt=""> <figcaption>CSES</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJhj319rR.png" alt=""> <figcaption>OJUZ</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/r1V9TycrR.png" alt=""> <figcaption>USACO</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SJTXn19BC.png" alt=""> <figcaption>DMOJ</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BJ_MnJ5S0.png" alt=""> <figcaption>VNOJ</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rkAAakcHA.png" alt=""> <figcaption>COCI</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/Bk9Uny9rR.png" alt=""> <figcaption>LQDOJ</figcaption> </figure> </td> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-d) Online Resources <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/r1HN6yqBC.png" alt=""> <figcaption>cp-algorithms</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/r1V9TycrR.png" alt=""> <figcaption>USACO</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJuwoJqHC.png" alt=""> <figcaption>Codeforces</figcaption> </figure> </td> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-e) Team Note <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/ByRIrvqrC.png" alt=""> <figcaption>Notion</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SJcedD5BA.png" alt=""> <figcaption>Confluence</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rkDEHw5SA.png" alt=""> <figcaption>HackMD</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SkwQLPqrR.png" alt=""> <figcaption>Slack</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SysZKP5HC.png" alt=""> <figcaption>Telegram</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/HJxU8v9SR.png" alt=""> <figcaption>Discord</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/HJOwLDcBR.png" alt=""> <figcaption>G-Drive</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/HkgqIPqrA.png" alt=""> <figcaption>G-Docs</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BJsNdDcBC.png" alt=""> <figcaption>G-Keep</figcaption> </figure> </td> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-f) Team Collaborating <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/Sy5FPwcS0.png" alt=""> <figcaption>Notion</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SkTaHPqSA.png" alt=""> <figcaption>CodeInterview</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/SkGRHv9BC.png" alt=""> <figcaption>Codeshare</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/rJ2CtD9BC.png" alt=""> <figcaption>Miro</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/H10rcP9S0.png" alt=""> <figcaption>LucidChart</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rJxXQDP5HA.png" alt=""> <figcaption>Excalidraw</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/S1T29w5HA.png" alt=""> <figcaption>Duckly</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/H1cVsDcSC.png" alt=""> <figcaption>Codeanywhere</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/BkTswDcHR.png" alt=""> <figcaption>Liveshare</figcaption> </figure> </td> </tr> </table> </center> ---- ### I.5 - Where to begin ? #### I.5-g) Extra <center> <table class="example-table"> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/BJEAku9HR.png" alt=""> <figcaption>????</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/rk1pJ_qBC.png" alt=""> <figcaption>Github</figcaption> </figure> </td> </tr> <tr> <td> <figure> <img src="https://hackmd.io/_uploads/SkoQx_5rC.png" alt=""> <figcaption>Gitlab</figcaption> </figure> </td> <td> <figure> <img src="https://hackmd.io/_uploads/Sk3Gxd9BR.png" alt=""> <figcaption>Git</figcaption> </figure> </td> </tr> </table> </center> --- ### I.6 - Try an online compiler <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/ByJ2Vw9S0.png" alt="" style="height: 250px;height:300px; width: 500px"> <figcaption>Online GDB</figcaption> </figure> ---- ### I.6 - Try an online compiler #### I.6-a) Write our first program ```cpp= #include <iostream> int main() { std::cout << "Hello World"; return 0; } ``` ---- ### I.6 - Try an online compiler #### I.6-b) Paste the code into OnlineGDB You can use hotkey: - `[Ctrl + A]` to select all - `[Ctrl + X]` to cut - `[Ctrl + C]` to copy - `[Ctrl + V]` to paste ![image](https://hackmd.io/_uploads/By79llqrC.png) ---- ### I.6 - Try an online compiler #### I.6-c) Select the `C++` language In competitive programming, please consider using: - `C`: Nah bro, we ain't gonna do that here `:(` - `C++11`: All Vietnamese compilers work fine. - `C++14`: Most Vietnamese compilers work fine. - `C++17`: Some Vietnamese compilers work fine. - `C++20`: Few Vietnamese compilers work fine. ![image](https://hackmd.io/_uploads/B1bgWgqSR.png) ---- ### I.6 - Try an online compiler #### I.6-d) Run the code You can use hotkey `[F9]` or click on `[RUN]` ![image](https://hackmd.io/_uploads/H1tOelqB0.png) ---- ### I.6 - Try an online compiler #### I.6-e) See the result ![image](https://hackmd.io/_uploads/ryITZeqB0.png) --- ### I.7 - Explaination <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJmSV4VUR.png" alt="" style="height: 250px; width: 500px"> <figcaption>Lets learn C++</figcaption> </figure> ---- ### I.7 - Explaination #### I.7-a) What are Comments ![image](https://hackmd.io/_uploads/S1HVzxqSC.png) ---- ### I.7 - Explaination #### I.7-b) The main function ```cpp= // main(): the default (non-asm) function to be called first int main() { // open bracket for the begin of the command of main() ... // execute these commands inside the main function return 0; // return int(0) means the code ran successfully } // close bracket for the end of the command of main() ``` ---- ### I.7 - Explaination #### I.7-c) The iostream library ```cpp= /** This is a valid multi-line comments * Whatever written here will be ignored **/ #include <iostream> // using library input-output-stream // By default, this provide you all these things, with std:: // std::cout, std::cin, std::cerr, ... // std::istream, std::ostream, ... // std::endl, std::flush, ... // std::string, std::stringstream, ... ``` ---- ### I.7 - Explaination #### I.7-d) The cout statement This is a statement to output anything inside `"..."` ```cpp= // this "<<" is just an operator for output // | // v std:: cout << "Hello World"; // ^ ^ ^^^^^^^^^^^ the output-result // | | // | c-out means "C++ please output" // | // namespace, to differentiate other function with a same name ``` ---- ### I.7 - Explaination #### I.7-e) Altogether ```cpp= // Library: Hey, could you give me some defined code for i/o ? #include <iostream> // ok, I will give you // C++: Hey, could you run this function first whatsoever ? int main() // sure, I am default to be run first { // C++: Hey, could you output these characters for me ? std::cout << "Hello World"; // sure, lol, why not ? // C++: You successfully ran the code return 0; // ok, I will return int(0) } ``` --- ### I.8 - Why do we stop here ? ![image](https://hackmd.io/_uploads/HydIulqr0.png) ---- ### I.8 - Why do we stop here ? #### I.8-a) Ignore the return ```cpp= #include <iostream> int main() { std::cout << "Hello World"; // only function main(): defaults to return zero on success } ``` ---- ### I.8 - Why do we stop here ? #### I.8-b) Writing into two parts ```cpp= #include <iostream> int main() { std::cout << "Hello " << "World"; // ^^ ^^ // || || // You can chain these two // to output more } ``` ---- ### I.8 - Why do we stop here ? #### I.8-c) Writing with multiple cout ```cpp= #include <iostream> int main() { std::cout << "Hello"; // output this std::cout << " "; // then output this std::cout << "World"; // finally output this } ``` ---- ### I.8 - Why do we stop here ? #### I.8-d) Writing into multiple lines ```cpp= #include <iostream> int main() { std::cout << "H" // start 1st here << "e"; // end 1st here std::cout << "l" // start 2nd here << "l" // << "o" // << " world"; // end 2nd here return 0; } ``` ---- ### I.8 - Why do we stop here ? #### I.8-e) Writing more or less characters ```cpp= #include <iostream> int main() { // output a pack of characters of a time (string) std::cout << "He" << "ll" << "o "; // output each character each time std::cout << 'W' << 'o' << 'r' << 'l' << 'd'; // notice that 'Wo' is a wide char, not string // we can output "World" as string, but not 'World' /// these quotes ^ ^ are different from ' ' } ``` ---- ### I.8 - Why do we stop here ? #### I.8-f) Using namespace ```cpp= #include <iostream> using namespace std; // we can use <name> as std::<name> int main() { // no need to type `std::cout`, we can use `cout` directly cout << "Hell"; cout << "o "; cout << "World"; } ``` --- ### I.9 - Do you love math ? ![image](https://hackmd.io/_uploads/H1f1FxqB0.png) ---- ### I.9 - Do you love math ? #### I.9-a) Input ```cpp= #include <iostream> int main() { int a, b; // Create two int (INTEGER) types, named a and b // ^^^ type(int) is builtin, so don't use `std::int` (invalid) std::cin >> a >> b; // cin (C-INPUT) two variables a and b } ``` ---- ### I.9 - Do you love math ? #### I.9-b) Basic operations ```cpp= #include <iostream> int main() { int a, b; std::cin >> a >> b; std::cout << a + b << std::endl; std::cout << a - b << std::endl; // ^ endl stands for end-line // it means we go down a line in terminal } ``` ---- ### I.9 - Do you love math ? #### I.9-c) Other common operations ```cpp= #include <iostream> int main() { int a, b; std::cin >> a >> b; std::cout << (a + b) << std::endl; // Add std::cout << (a - b) << std::endl; // Subtract std::cout << (a * b) << std::endl; // Multiply std::cout << (a / b) << std::endl; // Integer Divide std::cout << (a % b) << std::endl; // Mod } ``` ---- ### I.9 - Do you love math ? #### I.9-d) Comparisons ```cpp= #include <iostream> int main() { int a, b; std::cin >> a >> b; std::cout << (a < b) << std::endl; // Less std::cout << (a > b) << std::endl; // Greater std::cout << (a <= b) << std::endl; // Less or equal std::cout << (a >= b) << std::endl; // Greater or equal std::cout << (a == b) << std::endl; // Equal std::cout << (a != b) << std::endl; // Different } ``` ---- ### I.9 - Do you love math ? #### I.9-e) Bitwise operations ```cpp= #include <iostream> int main() { int a, b; std::cin >> a >> b; std::cout << (a | b) << std::endl; // OR std::cout << (a & b) << std::endl; // AND std::cout << (a ^ b) << std::endl; // XOR std::cout << (a << b) << std::endl; // SHIFT LEFT std::cout << (a >> b) << std::endl; // SHIFT RIGHT } ``` --- ## I.10 - The End <figure style="text-align: center;"> <img src="https://hackmd.io/_uploads/H1sr0DcBR.png" alt="" style="height:500px; width: 500px"> <figcaption>Any question ?</figcaption> </figure>
{"contributors":"[{\"id\":\"a22ea847-846d-438a-bc33-27664a818ea5\",\"add\":83004,\"del\":49379}]","title":"CodeMely slide 1","description":"\n\\begin{array}{c}\n\\texttt{C++ Competitive Programming Course}\\\\\n\\textbf{Introduction to Competitive Programming}\\\\\n\\end{array}\n"}
    251 views
   Owned this note