Skip to content

Commit

Permalink
Merge pull request #30 from luizacbcampos/site_correto
Browse files Browse the repository at this point in the history
Cria um site com todos os códigos
  • Loading branch information
brunomaletta committed May 10, 2024
2 parents dbcc61b + a195927 commit 5483f5c
Show file tree
Hide file tree
Showing 210 changed files with 16,018 additions and 8 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/github_page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy Hugo site to Pages

on:
push:
branches:
- master

# Allows manual triggering from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.123.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

- name: Get Hugo modules
run: |
hugo mod get
- name: Get baseURL from hugo.toml
id: get_base_url
run: |
echo "HUGO_BASE_URL=$(grep -Po '(?<=^baseURL = ")[^"]*' hugo.toml)" >> $GITHUB_ENV
- name: Build site with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
HUGO_BASE_URL: ${{ env.HUGO_BASE_URL }}
run: hugo --gc --minify --baseURL "${{ env.HUGO_BASE_URL }}/"

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Visual Studio Code
.vscode/
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
## User settings
xcuserdata/

## Xcode 8 and earlier
*.xcscmblueprint
*.xccheckout

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

*~
latex/biblioteca.tex
latex/biblioteca.log
latex/getlatex
Empty file added .hugo_build.lock
Empty file.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,42 @@ Biblioteca de algoritmos, estruturas de dados e primitivas para Maratona de Prog

Códigos em C++, em maior parte implementados pelos alunos da universidade.

#### PDF
### PDF

Versão em PDF dos algoritmos pode ser encontrada [aqui](https://github.com/brunomaletta/Biblioteca/blob/master/pdf/biblioteca.pdf).

O *theoretical guide* (documento com teoremas, identidades e informações teóricas relevantes) pode ser encontrado [aqui](https://github.com/brunomaletta/Biblioteca/blob/master/pdf/theoretical.pdf).

Link para o latex do theoretical: [link](https://www.overleaf.com/read/xrbtzvvkmkxs).

#### Atualizar o PDF

<details>
<summary>Detalhes</summary>

Para atualizar o PDF primeiro instale o latex executando
```
sudo apt install texlive-full
sudo apt install rubber
```
e então execute `./getlatex.sh` na pasta latex.
O pdf é gerado usando a ferramenta [rubber](https://gitlab.com/latex-rubber/rubber). Para baixá-la execute:

```
sudo apt install rubber
```
ou
```
pip install latex-rubber
```

O *theoretical guide* (documento com teoremas, identidades e informações teóricas relevantes) pode ser encontrado [aqui](https://github.com/brunomaletta/Biblioteca/blob/master/pdf/theoretical.pdf).
Por fim, execute

Link para o latex do theoretical: [link](https://www.overleaf.com/read/xrbtzvvkmkxs).
```
cd latex
./getlatex.sh
```
</details>

#### Hash
### Hash

No PDF, a coluna de hash é o hash de cada linha, exceto se a linha contem um caractere `}`. Nesse caso, o hash da linha é o hash a partir da linha que fecha o último `}` da linha atual.

Expand Down
Binary file added assets/images/balloon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logos/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/images/logos/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/images/logos/mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions content/docs/DP/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
weight: 10
title: "DP"
draft: false
date: "2024-05-09T18:39:19-0300"
description: ""
publishdate: "2024-05-09T18:39:19-0300"
---
45 changes: 45 additions & 0 deletions content/docs/DP/dcDp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
weight: 10
title: "Divide and Conquer DP"
draft: false
toc: true
date: "2024-05-09T18:39:19-0300"
publishdate: "2024-05-09T18:39:19-0300"
description: ""
---

## Sobre
Particiona o array em k subarrays

minimizando o somatorio das queries



O(k n log n), assumindo quer query(l, r) eh O(1)



Link original: [dcDp.cpp](https://github.com/brunomaletta/Biblioteca/tree/master/Codigo/DP/dcDp.cpp)

## Código
```cpp
ll dp[MAX][2];

void solve(int k, int l, int r, int lk, int rk) {
if (l > r) return;
int m = (l+r)/2, p = -1;
auto& ans = dp[m][k&1] = LINF;
for (int i = max(m, lk); i <= rk; i++) {
ll at = dp[i+1][~k&1] + query(m, i);
if (at < ans) ans = at, p = i;
}
solve(k, l, m-1, lk, p), solve(k, m+1, r, p, rk);
}

ll DC(int n, int k) {
dp[n][0] = dp[n][1] = 0;
for (int i = 0; i < n; i++) dp[i][0] = LINF;
for (int i = 1; i <= k; i++) solve(i, 0, n-i, 0, n-i);
return dp[0][k&1];
}
```
94 changes: 94 additions & 0 deletions content/docs/DP/lcs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
weight: 10
title: "Longest Common Subsequence"
draft: false
toc: true
date: "2024-05-09T18:39:19-0300"
publishdate: "2024-05-09T18:39:19-0300"
description: ""
---

## Sobre
Computa a LCS entre dois arrays usando

o algoritmo de Hirschberg para recuperar



O(n*m), O(n+m) de memoria



Link original: [lcs.cpp](https://github.com/brunomaletta/Biblioteca/tree/master/Codigo/DP/lcs.cpp)

## Código
```cpp
int lcs_s[MAX], lcs_t[MAX];
int dp[2][MAX];

// dp[0][j] = max lcs(s[li...ri], t[lj, lj+j])
void dp_top(int li, int ri, int lj, int rj) {
memset(dp[0], 0, (rj-lj+1)*sizeof(dp[0][0]));
for (int i = li; i <= ri; i++) {
for (int j = rj; j >= lj; j--)
dp[0][j - lj] = max(dp[0][j - lj],
(lcs_s[i] == lcs_t[j]) + (j > lj ? dp[0][j-1 - lj] : 0));
for (int j = lj+1; j <= rj; j++)
dp[0][j - lj] = max(dp[0][j - lj], dp[0][j-1 -lj]);
}
}

// dp[1][j] = max lcs(s[li...ri], t[lj+j, rj])
void dp_bottom(int li, int ri, int lj, int rj) {
memset(dp[1], 0, (rj-lj+1)*sizeof(dp[1][0]));
for (int i = ri; i >= li; i--) {
for (int j = lj; j <= rj; j++)
dp[1][j - lj] = max(dp[1][j - lj],
(lcs_s[i] == lcs_t[j]) + (j < rj ? dp[1][j+1 - lj] : 0));
for (int j = rj-1; j >= lj; j--)
dp[1][j - lj] = max(dp[1][j - lj], dp[1][j+1 - lj]);
}
}

void solve(vector<int>& ans, int li, int ri, int lj, int rj) {
if (li == ri){
for (int j = lj; j <= rj; j++)
if (lcs_s[li] == lcs_t[j]){
ans.push_back(lcs_t[j]);
break;
}
return;
}
if (lj == rj){
for (int i = li; i <= ri; i++){
if (lcs_s[i] == lcs_t[lj]){
ans.push_back(lcs_s[i]);
break;
}
}
return;
}
int mi = (li+ri)/2;
dp_top(li, mi, lj, rj), dp_bottom(mi+1, ri, lj, rj);

int j_ = 0, mx = -1;

for (int j = lj-1; j <= rj; j++) {
int val = 0;
if (j >= lj) val += dp[0][j - lj];
if (j < rj) val += dp[1][j+1 - lj];

if (val >= mx) mx = val, j_ = j;
}
if (mx == -1) return;
solve(ans, li, mi, lj, j_), solve(ans, mi+1, ri, j_+1, rj);
}

vector<int> lcs(const vector<int>& s, const vector<int>& t) {
for (int i = 0; i < s.size(); i++) lcs_s[i] = s[i];
for (int i = 0; i < t.size(); i++) lcs_t[i] = t[i];
vector<int> ans;
solve(ans, 0, s.size()-1, 0, t.size()-1);
return ans;
}
```
Loading

0 comments on commit 5483f5c

Please sign in to comment.