### LaTeX for Time Complexity Explanation Source: https://context7.com/pllk/cphb/llms.txt Illustrates how to explain time complexity using LaTeX, including the standard O-notation and examples for single and nested loops. It defines keywords for emphasis. ```latex \section{Time complexity} The \key{time complexity} of an algorithm estimates how much time the algorithm will use for some input. The time complexity is denoted $O(\cdots)$ where the parameter is the size of the input. For example, the time complexity of the following code is $O(n)$: \begin{lstlisting} for (int i = 1; i <= n; i++) { // code } \end{lstlisting} For nested loops, the time complexity is $O(n^k)$ where $k$ is the number of nested loops. ``` -------------------------------- ### LaTeX Document Setup for Competitive Programmer's Handbook Source: https://context7.com/pllk/cphb/llms.txt Configures the main LaTeX document for the handbook, including document class, packages, title, author, and chapter inclusion. It sets up the basic structure for the book. ```latex \documentclass[twoside,12pt,a4paper,english]{book} \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage[table]{xcolor} \usepackage{tikz} \usepackage{hyperref} \usepackage{fouriernc} \usepackage[T1]{fontenc} \title{\Huge Competitive Programmer's Handbook} \author{\Large Antti Laaksonen} \begin{document} \frontmatter \maketitle \tableofcontents \include{preface} \mainmatter \part{Basic techniques} \include{chapter01} \include{chapter02} % ... additional chapters \printindex \end{document} ``` -------------------------------- ### Standard C++ Template and Implementation Source: https://context7.com/pllk/cphb/llms.txt Provides a basic C++ template and a more detailed implementation example commonly used in competitive programming. It includes standard headers, input/output, and a vector usage pattern. ```latex \begin{lstlisting} #include using namespace std; int main() { // solution comes here } \end{lstlisting} ``` ```cpp // Actual C++ implementation #include using namespace std; int main() { int n; cin >> n; vector data(n); for (int i = 0; i < n; i++) { cin >> data[i]; } // Process and solve problem cout << result << "\n"; return 0; } ``` -------------------------------- ### C++ Code Highlighting Configuration in LaTeX Source: https://context7.com/pllk/cphb/llms.txt Defines color schemes and styling for C++ code snippets within the LaTeX document using the 'listings' package. This ensures consistent and readable code examples. ```latex \definecolor{keywords}{HTML}{44548A} \definecolor{strings}{HTML}{00999A} \definecolor{comments}{HTML}{990000} \lstset{ language=C++, frame=single, basicstyle=\ttfamily \small, showstringspaces=false, columns=flexible, xleftmargin=20pt, xrightmargin=5pt, aboveskip=12pt, belowskip=8pt, commentstyle=\color{comments}, keywordstyle=\color{keywords}, stringstyle=\color{strings} } ``` -------------------------------- ### Book Compilation Workflow using pdflatex Source: https://context7.com/pllk/cphb/llms.txt Outlines the command-line steps to compile the LaTeX document into a PDF, including steps for index generation and multiple LaTeX runs for finalization. This is the standard workflow for building the handbook. ```bash # Compile the book with pdflatex pdflatex book.tex # Generate index makeindex book.idx # Final compilation for complete references pdflatex book.tex pdflatex book.tex # Output: book.pdf (complete handbook) ``` -------------------------------- ### Organize Book Chapters with LaTeX Source: https://context7.com/pllk/cphb/llms.txt This LaTeX code demonstrates how to structure a book using a modular chapter system. It uses \part to divide sections and \include to incorporate individual chapters, allowing for organized content management. ```latex % book.tex includes all chapters \part{Basic techniques} \include{chapter01} % Introduction \include{chapter02} % Time complexity \include{chapter03} % Sorting \include{chapter04} % Data structures \include{chapter05} % Dynamic programming % ... chapters 06-10 \part{Graph algorithms} \include{chapter11} % Basics of graphs \include{chapter12} % Graph traversal % ... chapters 13-20 \part{Advanced topics} \include{chapter21} % Number theory \include{chapter22} % Combinatorics % ... chapters 23-30 ``` -------------------------------- ### Front Matter Structure in LaTeX Source: https://context7.com/pllk/cphb/llms.txt This LaTeX snippet demonstrates how to structure the front matter of a book, specifically a preface. It includes commands for unnumbered chapters, header marking, and adding the preface to the table of contents. ```latex \chapter*{Preface} \markboth{\MakeUppercase{Preface}}{} \addcontentsline{toc}{chapter}{Preface} The purpose of this book is to give you a thorough introduction to competitive programming. It is assumed that you already know the basics of programming, but no previous background in competitive programming is needed. The book is especially intended for students who want to learn algorithms and possibly participate in the International Olympiad in Informatics (IOI) or the International Collegiate Programming Contest (ICPC). \begin{flushright} Helsinki, August 2019 \\ Antti Laaksonen \end{flushright} ``` -------------------------------- ### Mathematical Notation in LaTeX Source: https://context7.com/pllk/cphb/llms.txt This LaTeX snippet shows how to integrate mathematical notation for algorithm analysis. It defines terms like 'factor' and 'prime' and uses LaTeX's display math environment for equations and prime decomposition. ```latex \section{Primes and factors} A number $a$ is called a \key{factor} of a number $b$ if $a$ divides $b$. We write $a \mid b$ if $a$ is a factor, otherwise $a \nmid b$. For example, consider the equation: \[x^3 + y^3 + z^3 = 33\] A number $n>1$ is a \key{prime} if its only positive factors are 1 and $n$ itself. The prime decomposition of a number can be expressed as: \[n = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}\] ``` -------------------------------- ### Custom Styling and Typography in LaTeX Source: https://context7.com/pllk/cphb/llms.txt This LaTeX code configures custom styling for a book. It includes packages for page geometry, fonts, and customizes the formatting of subsubsection titles and defines a command for bold keywords. ```latex \usepackage[a4paper,vmargin=30mm,hmargin=33mm,footskip=15mm]{geometry} \usepackage{fouriernc} \usepackage[scaled=0.95]{inconsolata} \titleformat{\subsubsection} {\normalfont\large\bfseries\sffamily}{\thesubsection}{1em}{} \newcommand{\key}[1]{\textbf{#1}} % Usage in chapters: The \key{design of algorithms} consists of problem solving and mathematical thinking. ``` -------------------------------- ### LaTeX for Graph Terminology and Visualization Source: https://context7.com/pllk/cphb/llms.txt Demonstrates how to define graph terminology and create visual representations of graphs using TikZ within a LaTeX document. It includes node and edge definitions. ```latex \section{Graph terminology} A \key{graph} consists of \key{nodes} and \key{edges}. The variable $n$ denotes the number of nodes and $m$ denotes the number of edges. \begin{center} \begin{tikzpicture}[scale=0.9] \node[draw, circle] (1) at (1,3) {$1$}; \node[draw, circle] (2) at (4,3) {$2$}; \node[draw, circle] (3) at (1,1) {$3$}; \node[draw, circle] (4) at (4,1) {$4$}; \node[draw, circle] (5) at (6,2) {$5$}; \path[draw,thick,-] (1) -- (2); \path[draw,thick,-] (1) -- (3); \path[draw,thick,-] (3) -- (4); \path[draw,thick,-] (2) -- (5); \end{tikzpicture} \end{center} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.