-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from BRUTEUdesc/joao
Refatoracao geral
- Loading branch information
Showing
105 changed files
with
7,057 additions
and
1,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
\documentclass[11pt, a4paper, twoside]{article} | ||
\usepackage[T1]{fontenc} | ||
\usepackage[utf8]{inputenc} | ||
\usepackage{amssymb,amsmath} | ||
\usepackage[portuguese]{babel} | ||
\usepackage{comment} | ||
\usepackage{datetime} | ||
\usepackage[pdfusetitle]{hyperref} | ||
\usepackage[all]{xy} | ||
\usepackage{graphicx} | ||
\addtolength{\parskip}{.5\baselineskip} | ||
|
||
\usepackage{xcolor} | ||
\usepackage{listings} %biblioteca pro codigo | ||
|
||
\usepackage{multicol} %biblioteca pra duas colunas | ||
\setlength{\columnseprule}{0.2pt} | ||
\setlength{\columnsep}{10pt} %distancia do texto ate a barra | ||
\def\columnseprulecolor{\color{black}} | ||
|
||
\usepackage{color} %deixa o codigo colorido bonitinho | ||
\usepackage[portrait, left=2cm, right=1.5cm, top=2cm, bottom=2cm]{geometry} | ||
|
||
\definecolor{gray}{rgb}{0.2, 0.2, 0.2} %cor pros comentarios | ||
\renewcommand{\footnotesize}{\small} %isso eh pra mudar o tamanho da fonte do codigo | ||
|
||
\lstset{ %opcoes pro codigo | ||
language=C++, | ||
breaklines=true, | ||
keywordstyle=\color{black}\bfseries, | ||
commentstyle=\color{darkgray}, | ||
breakatwhitespace=true, | ||
%frame=single, | ||
numbers=left, | ||
rulecolor=\color{black}, | ||
showstringspaces=false | ||
stringstyle=\color{purple}, | ||
tabsize=2, | ||
basicstyle=\footnotesize, | ||
% basicstyle=\ttfamily\footnotesize, % fonte pro codigo, nao sei qual dos dois eu prefiro | ||
} | ||
\lstset{literate= | ||
% *{0}{{{\color{red!20!violet}0}}}1 | ||
% {1}{{{\color{red!20!violet}1}}}1 | ||
% {2}{{{\color{red!20!violet}2}}}1 | ||
% {3}{{{\color{red!20!violet}3}}}1 | ||
% {4}{{{\color{red!20!violet}4}}}1 | ||
% {5}{{{\color{red!20!violet}5}}}1 | ||
% {6}{{{\color{red!20!violet}6}}}1 | ||
% {7}{{{\color{red!20!violet}7}}}1 | ||
% {8}{{{\color{red!20!violet}8}}}1 | ||
% {9}{{{\color{red!20!violet}9}}}1 | ||
% {l}{$\text{l}$}1 | ||
{~}{$\sim$}{1} % ~ bonitinho | ||
} | ||
|
||
\title{BRUTE \\ UDESC} | ||
\author{Eliton Machado da Silva, Enzo de Almeida Rodrigues, Eric Grochowicz, \\ João Vitor Frölich, João Marcos de Oliveira e Rafael Granza de Mello} | ||
|
||
\begin{document} | ||
% \twocolumn | ||
\date{\today} | ||
\maketitle | ||
|
||
|
||
\renewcommand{\contentsname}{Índice} %troca o nome do indice para indice | ||
\tableofcontents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# AlmanaqueNTJ | ||
|
||
Repositório de códigos para programação competitiva do NTJ com latex copiado da UFMG. | ||
Ainda em desenvolvimento. | ||
|
||
### Pasta `codigos` | ||
|
||
Todas as implementações estão nessa pasta. | ||
|
||
### Pasta `latex` | ||
|
||
Aqui estão os scripts necessários para gerar o latex e o pdf do Almanaque, com base nos códigos que estão na pasta `codigos`. O arquivo `almanaque.tex` também está nessa pasta. | ||
|
||
Aqui também estão os arquivos `INICIO_README.md` e `INICIO_LATEX.tex`, que são usados como cabeçalho para os arquivos `README.md` e `almanaque.tex`, respectivamente. Se quiser alterar o README ou as configurações do latex, edite sempre esses arquivos. | ||
|
||
Após qualquer alteração nos códigos ou nos arquivos `INICIO*`, basta rodar o `update.sh`, que vai atualizar o `.tex` e o `.pdf` do Almanaque, bem como atualizar o README. | ||
|
||
OBS: Antes de rodar o update.sh, rode os seguintes comandos para instalar o latex: | ||
|
||
``` | ||
sudo apt install texlive-full | ||
sudo apt install rubber | ||
``` | ||
|
||
### Pasta `pdf` | ||
|
||
Aqui está o `.pdf` do Almanaque. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,133 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# this script will generate a latex file with all the cpp code in the repo | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
from markdown import markdown | ||
|
||
def output_readme(file: Path): | ||
s = file.open().read().replace("*Read in [English](README.en.md)*", "").replace("_Read in [English](README.en.md)_", "") | ||
if str(file).count("/") == 2: | ||
# print(s) | ||
# while s.startswith("\n"): | ||
# s = s[1:] | ||
# s = "#" + s | ||
new_s = '' | ||
for line in s.splitlines(): | ||
if line.startswith("# "): | ||
line = "#" + line + '\n\n' | ||
# print("132- "+line) | ||
new_s += line + '\n' | ||
s = new_s | ||
if str(file).count("/") == 1: | ||
s = "<div style=\"page-break-after: always;\"></div>\n" + s | ||
return s | ||
|
||
def output_code(file: Path): | ||
formated_text = "```c++\n" + file.open().read() + "\n```\n" | ||
return formated_text | ||
|
||
|
||
def output_dir(dir_path: Path): | ||
if (dir_path / "README.md").is_file(): | ||
yield "-----" | ||
yield output_readme(dir_path / "README.md") | ||
for path in dir_path.iterdir(): | ||
if path.name.startswith('.'): | ||
pass | ||
if path.is_dir(): | ||
yield from output_dir(path) | ||
elif path.name.endswith('.cpp'): | ||
yield f"### *Implementação {path.stem}*:".title().replace('_', " ") | ||
yield output_code(path) | ||
def printa_arquivo(path: Path, FILE: Path): | ||
with open(path, "r") as f: | ||
FILE.write(f.read()) | ||
|
||
def printa_readme(path: Path, FILE: Path): | ||
with open(path, "r") as f: | ||
in_code = False | ||
|
||
for line in f.readlines(): | ||
if line.startswith("```"): | ||
if in_code: | ||
FILE.write("\\end{lstlisting}\n\n") | ||
in_code = False | ||
else: | ||
FILE.write("\\begin{lstlisting}[language=C++]\n") | ||
in_code = True | ||
|
||
elif in_code: | ||
FILE.write(line) | ||
|
||
elif (line.startswith("#")): | ||
it = 0 | ||
while (line[it] == "#" or line[it] == " "): | ||
it += 1 | ||
name = line[it:-1] | ||
if name[0] == '[': | ||
name = name[1:name.find(']')] | ||
FILE.write(f"\\subsection{{{name}}}\n\n") | ||
|
||
elif "English" in line: | ||
pass | ||
|
||
else: | ||
in_inline_code = False | ||
for i in range(len(line)): | ||
if line[i] == '`': | ||
if in_inline_code: | ||
FILE.write("}") | ||
else: | ||
FILE.write("\\lstinline{") | ||
in_inline_code = not in_inline_code | ||
else: | ||
# if line[i] in ['_', '&', '%', '#', '{', '}']: | ||
# FILE.write('\\') | ||
if line[i] in ['_', '%']: | ||
FILE.write('\\') | ||
FILE.write(line[i]) | ||
|
||
FILE.write("\n") | ||
|
||
def printa_codigo(path: Path, FILE: Path): | ||
max_width = 55 | ||
two_columns = True | ||
|
||
with open(path, "r") as f: | ||
lines = f.readlines() | ||
for line in lines: | ||
if len(line) > max_width: | ||
two_columns = False | ||
break | ||
|
||
if two_columns: | ||
FILE.write("\\begin{multicols}{2}\n") | ||
|
||
FILE.write("\\begin{lstlisting}[language=C++]\n") | ||
with open(path, "r") as f: | ||
FILE.write(f.read()) | ||
FILE.write("\\end{lstlisting}\n") | ||
|
||
if two_columns: | ||
FILE.write("\\end{multicols}\n") | ||
FILE.write("\n") | ||
|
||
|
||
def printa_section(section: str, FILE: Path): | ||
FILE.write("\\newpage\n") | ||
|
||
FILE.write("%%%%%%\n") | ||
for i in range(2): | ||
FILE.write("%\n") | ||
FILE.write(f"% {section}\n") | ||
for i in range(2): | ||
FILE.write("%\n") | ||
FILE.write("%%%%%%\n\n") | ||
|
||
FILE.write(f"\\section{{{section}}}\n\n") | ||
|
||
def printa_subsection(subsection: str, FILE: Path): | ||
FILE.write(f"\\subsection{{{subsection}}}\n\n") | ||
|
||
def dfs(path: Path, FILE: Path): | ||
tem_codigo = True | ||
for child in path.iterdir(): | ||
if child.is_dir(): | ||
dfs(child, FILE) | ||
tem_codigo = False | ||
|
||
if tem_codigo: | ||
printa_subsection(path.name, FILE) | ||
|
||
|
||
READMES = [x for x in path.glob("*.md") if not "en" in x.name] | ||
for readme in READMES: | ||
printa_readme(readme, FILE) | ||
|
||
CODIGOS = list(path.glob("*.cpp")) | ||
for codigo in CODIGOS: | ||
printa_codigo(codigo, FILE) | ||
|
||
|
||
if __name__ == "__main__": | ||
md = output_dir(Path('.')) | ||
html = markdown("\n".join(md), extensions=["fenced_code"]) | ||
with open("Almanaque.html", "w") as f: | ||
f.write(html) | ||
f.close() | ||
print("Created Almanaque.html") | ||
|
||
ALMANAQUE = Path("LaTeX/Almanaque.tex") | ||
with open(ALMANAQUE, "w") as f: | ||
INICIO = Path(".github/files/INICIO_LATEX.tex") | ||
printa_arquivo(INICIO, f) | ||
|
||
DIR = Path("Codigos") | ||
for child in DIR.iterdir(): | ||
if child.is_dir(): | ||
printa_section(child.name, f) | ||
dfs(child, f) | ||
f.write("\\end{document}\n") | ||
|
||
|
||
else: | ||
print("Function not called correctly, please try again.") | ||
print("Esse script não deve ser importado, apenas executado.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
on: [push, pull_request] | ||
on: push | ||
name: clang-format Code Formatter | ||
jobs: | ||
lint: | ||
name: clang-format Code Formatter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clang Code Formatter | ||
uses: ivanludvig/clang-format-action@v1.4 | ||
uses: joaomarcosth9/clang-format-action@1.3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ out | |
out.* | ||
*.out | ||
venv | ||
Almanaque.html | ||
.idea | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
struct bipartite_dsu{ | ||
vector<int> parent; | ||
struct bipartite_dsu { | ||
vector<int> parent; | ||
vector<int> color; | ||
int size; | ||
bipartite_dsu(int n){ | ||
bipartite_dsu(int n) { | ||
size = n; | ||
color.resize(n+5, 0); | ||
for(int i = 0; i<n+5; ++i) parent.push_back(i); | ||
color.resize(n + 5, 0); | ||
for (int i = 0; i < n + 5; ++i) { parent.push_back(i); } | ||
} | ||
pair<int, bool> get(int a){ | ||
if(parent[a] == a) return {a, 0}; | ||
|
||
pair<int, bool> get(int a) { | ||
if (parent[a] == a) { return {a, 0}; } | ||
auto val = get(parent[a]); | ||
parent[a] = val.fi; | ||
color[a] = (color[a] + val.se) % 2; | ||
return {parent[a], color[a]}; | ||
} | ||
|
||
bool same_color(int a, int b){get(a); get(b); return color[a] == color[b];} | ||
bool same_group(int a, int b){get(a); get(b); return parent[a] == parent[b];} | ||
bool possible_edge(int a, int b){return !same_color(a, b) || !same_group(a, b);} | ||
|
||
void join(int a, int b){ | ||
auto val_a = get(a), val_b =get(b); | ||
|
||
bool same_color(int a, int b) { | ||
get(a); | ||
get(b); | ||
return color[a] == color[b]; | ||
} | ||
bool same_group(int a, int b) { | ||
get(a); | ||
get(b); | ||
return parent[a] == parent[b]; | ||
} | ||
bool possible_edge(int a, int b) { return !same_color(a, b) || !same_group(a, b); } | ||
|
||
void join(int a, int b) { | ||
auto val_a = get(a), val_b = get(b); | ||
parent[val_a.fi] = val_b.fi; | ||
color[val_a.fi] = (val_a.se + val_b.se + 1)%2; | ||
color[val_a.fi] = (val_a.se + val_b.se + 1) % 2; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.