# ouou-beep/algorithm architecture

> Architecture diagram of the GitHub repository ouou-beep/algorithm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ouou-beep/algorithm
- Repository: https://github.com/ouou-beep/algorithm

## Overview

This repository is a collection of independent C++ algorithm exercises, not a shared application. Each program reads a problem-specific input from standard input, performs an algorithm, and writes its result to standard output. The graph groups the exercises by algorithm family and shows internal helper calls where visible in the excerpts. There is no shared runtime or orchestration layer; the edges reflect only the console interactions and calls shown in source.

Main entry points: [`others/sort_n_search.cpp`](https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp) (Sort and search), [`luogu/luoguP2216.cpp`](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp) (Matrix range minimum), [`luogu/luoguP1801.cpp`](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1801.cpp) (Black Box median), [`luogu/luoguP1160.cpp`](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1160.cpp) (Queue editing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sequence["Sequences and queues"]
  node_p1160["Queue editing<br/>[luoguP1160.cpp]"]
  node_p1801["Black Box median<br/>[luoguP1801.cpp]"]
  node_p1801get["GET operation<br/>[luoguP1801.cpp]"]
  node_p5788["Next greater index<br/>[luoguP5788.cpp]"]
end

subgraph group_ordering["Ordering and search"]
  node_p1631["Smallest sums<br/>[luoguP1631.cpp]"]
  node_merge["Merge sort<br/>[merge.cpp]"]
  node_sortsearch["Sort and search<br/>[sort_n_search.cpp]"]
  node_quicksort["Quick sort<br/>[sort_n_search.cpp]"]
  node_binarysearch["Binary search<br/>[sort_n_search.cpp]"]
end

subgraph group_combinatorial["Combinatorial algorithms"]
  node_p1706["Permutations<br/>[luoguP1706.cpp]"]
  node_p1706all["Permutation recursion<br/>[luoguP1706.cpp]"]
  node_p2216["Matrix range minimum<br/>[luoguP2216.cpp]"]
  node_p2216max["Window maxima<br/>[luoguP2216.cpp]"]
  node_p2216min["Window minima<br/>[luoguP2216.cpp]"]
end

node_stdin(("Standard input"))
node_stdout(("Standard output"))

node_stdin -->|"provides input"| node_p1160
node_p1160 -->|"prints queue"| node_stdout
node_stdin -->|"provides input"| node_p1631
node_p1631 -->|"prints sums"| node_stdout
node_stdin -->|"provides input"| node_p1801
node_p1801 -->|"calls GET"| node_p1801get
node_p1801 -->|"prints results"| node_stdout
node_stdin -->|"provides input"| node_p1706
node_p1706 -->|"calls recursion"| node_p1706all
node_p1706all -->|"prints permutations"| node_stdout
node_stdin -->|"provides input"| node_p2216
node_p2216 -->|"calls Max2D"| node_p2216max
node_p2216 -->|"calls Min2D"| node_p2216min
node_p2216 -->|"prints minimum difference"| node_stdout
node_stdin -->|"provides input"| node_p5788
node_p5788 -->|"prints indices"| node_stdout
node_stdin -->|"provides input"| node_merge
node_merge -->|"prints sorted values"| node_stdout
node_stdin -->|"provides input"| node_sortsearch
node_sortsearch -->|"calls quick sort"| node_quicksort
node_sortsearch -->|"calls binary search"| node_binarysearch
node_sortsearch -->|"prints search result"| node_stdout

click node_p1160 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1160.cpp"
click node_p1631 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1631.cpp"
click node_p1801 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1801.cpp"
click node_p1801get "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1801.cpp"
click node_p1706 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1706.cpp"
click node_p1706all "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1706.cpp"
click node_p2216 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp"
click node_p2216max "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp"
click node_p2216min "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp"
click node_p5788 "https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP5788.cpp"
click node_merge "https://github.com/ouou-beep/algorithm/blob/master/others/merge.cpp"
click node_sortsearch "https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp"
click node_quicksort "https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp"
click node_binarysearch "https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_p1160,node_p1801,node_p1801get,node_p5788 toneBlue
class node_p1631,node_merge,node_sortsearch,node_quicksort,node_binarysearch toneAmber
class node_p1706,node_p1706all,node_p2216,node_p2216max,node_p2216min toneMint
class node_stdin,node_stdout toneIndigo
```

## Components

### Sequences and queues

- [Queue editing](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1160.cpp): `luogu/luoguP1160.cpp`
- [Black Box median](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1801.cpp): `luogu/luoguP1801.cpp`
- [GET operation](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1801.cpp): `luogu/luoguP1801.cpp`
- [Next greater index](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP5788.cpp): `luogu/luoguP5788.cpp`

### Ordering and search

- [Smallest sums](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1631.cpp): `luogu/luoguP1631.cpp`
- [Merge sort](https://github.com/ouou-beep/algorithm/blob/master/others/merge.cpp): `others/merge.cpp`
- [Sort and search](https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp): `others/sort_n_search.cpp`
- [Quick sort](https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp): `others/sort_n_search.cpp`
- [Binary search](https://github.com/ouou-beep/algorithm/blob/master/others/sort_n_search.cpp): `others/sort_n_search.cpp`

### Combinatorial algorithms

- [Permutations](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1706.cpp): `luogu/luoguP1706.cpp`
- [Permutation recursion](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP1706.cpp): `luogu/luoguP1706.cpp`
- [Matrix range minimum](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp): `luogu/luoguP2216.cpp`
- [Window maxima](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp): `luogu/luoguP2216.cpp`
- [Window minima](https://github.com/ouou-beep/algorithm/blob/master/luogu/luoguP2216.cpp): `luogu/luoguP2216.cpp`

### Other components

- **Standard input**
- **Standard output**

## Connections

- Standard input → Queue editing: provides input (evidence: `luogu/luoguP1160.cpp`)
- Queue editing → Standard output: prints queue (evidence: `luogu/luoguP1160.cpp`)
- Standard input → Smallest sums: provides input (evidence: `luogu/luoguP1631.cpp`)
- Smallest sums → Standard output: prints sums (evidence: `luogu/luoguP1631.cpp`)
- Standard input → Black Box median: provides input (evidence: `luogu/luoguP1801.cpp`)
- Black Box median → GET operation: calls GET (evidence: `luogu/luoguP1801.cpp`)
- Black Box median → Standard output: prints results (evidence: `luogu/luoguP1801.cpp`)
- Standard input → Permutations: provides input (evidence: `luogu/luoguP1706.cpp`)
- Permutations → Permutation recursion: calls recursion (evidence: `luogu/luoguP1706.cpp`)
- Permutation recursion → Standard output: prints permutations (evidence: `luogu/luoguP1706.cpp`)
- Standard input → Matrix range minimum: provides input (evidence: `luogu/luoguP2216.cpp`)
- Matrix range minimum → Window maxima: calls Max2D (evidence: `luogu/luoguP2216.cpp`)
- Matrix range minimum → Window minima: calls Min2D (evidence: `luogu/luoguP2216.cpp`)
- Matrix range minimum → Standard output: prints minimum difference (evidence: `luogu/luoguP2216.cpp`)
- Standard input → Next greater index: provides input (evidence: `luogu/luoguP5788.cpp`)
- Next greater index → Standard output: prints indices (evidence: `luogu/luoguP5788.cpp`)
- Standard input → Merge sort: provides input (evidence: `others/merge.cpp`)
- Merge sort → Standard output: prints sorted values (evidence: `others/merge.cpp`)
- Standard input → Sort and search: provides input (evidence: `others/sort_n_search.cpp`)
- Sort and search → Quick sort: calls quick sort (evidence: `others/sort_n_search.cpp`)
- Sort and search → Binary search: calls binary search (evidence: `others/sort_n_search.cpp`)
- Sort and search → Standard output: prints search result (evidence: `others/sort_n_search.cpp`)
