Skip to content

Commit

Permalink
Merge pull request #14 from propilideno/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
propilideno authored Jul 25, 2023
2 parents 68daa51 + 3c9bfd0 commit ca1ded9
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 61 deletions.
8 changes: 4 additions & 4 deletions buildLab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ selectTemplate(){
while true; do
echo -e "\e[90m=========\e[0m Select your \e[32mC++ Template\e[0m \e[90m=========\e[0m"
echo -e "If you don't know what choose, select \e[32mBasic\e[0m"
echo -e "\e[32m1\e[0m) \e[32mBasic\e[0m - 26 lines"
echo -e "\e[33m2\e[0m) \e[33mStandard\e[0m - 39 lines"
echo -e "\e[31m3\e[0m) \e[31mComplex\e[0m - 57 lines"
echo -e "\e[95m4\e[1m) \e[95mMaster\e[0m - 98 lines"
echo -e "\e[32m1\e[0m) \e[32mBasic\e[0m - 32 lines"
echo -e "\e[33m2\e[0m) \e[33mStandard\e[0m - 40 lines"
echo -e "\e[31m3\e[0m) \e[31mComplex\e[0m - 58 lines"
echo -e "\e[95m4\e[1m) \e[95mMaster\e[0m - 101 lines"
gray "============================================"
echo -n "My choice is: "
read -r choice
Expand Down
Empty file added templates/cpp/README.md
Empty file.
14 changes: 10 additions & 4 deletions templates/cpp/basic.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
// ############################ Template available in: https://propi.dev/cp ############################ //
/* ######################## Template available in: https://propi.dev/cp ######################## */
#include <bits/stdc++.h>
//Debug methods
#define _(x) {cout << #x << " = " << x << endl;} //Print with endl
#define __(x) {cout << #x << " = " << x << " | ";} //Print without endl
#define _vec(x) {cout << #x << " = "; for(int i : x){cout << i << " ";} cout << endl;} //Print entire vector
#define __log__ { std::FILE* file = std::freopen("LOG.txt", "w", stdout); } //Redirect output to LOG.txt
#define __time__ { auto duration = chrono::duration<double>( /* Show runtime */ \
std::chrono::high_resolution_clock::now() - beg); cout<<"Time: "<<duration.count()<<endl;}
//Constants
const auto beg = std::chrono::high_resolution_clock::now(); //Begining of the program
const double PI = acos(-1);
//IO Optimization
#define SpeedUP ios_base::sync_with_stdio(false); //If false, don't use stdio and iostream at the same time
#define __FasterIO__ ios_base::sync_with_stdio(false); //Don't use stdio and iostream at the same time
//Types
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
// ###################################################################################################### //
/* ############################################################################################## */

int main(){
//SpeedUP; //Uncomment for a faster runtime
//__FasterIO__ //Uncomment for improve runtime
//__log__ //Uncomment for redirect output to LOG.txt
string line;
while(getline(cin,line)){
cout << line << endl;
}

//__time__ //Uncomment for show runtime
}
15 changes: 8 additions & 7 deletions templates/cpp/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
#define _pair(x) {cout << #x << " = | " << "1st: " << x.first << " | " << "2nd: " << x.second << endl;} //Print pair
#define __time__ { auto duration = chrono::duration<double>( /* Show runtime */ \
std::chrono::high_resolution_clock::now() - beg); cout<<"Time: "<<duration.count()<<endl;}
#define __log__ { std::FILE* file = std::freopen("LOG.txt", "w", stdout); }
//Constants
const auto beg = std::chrono::high_resolution_clock::now(); //Begining of the program
const double PI = acos(-1); //PI
const double E = 1e-8; //Small Number (10^-8)
const int INF_P = 0x3f3f3f3f; //Max positive integer that don't cause overflow when doubled
const int INF_N = 0xcfcfcfcf; //Min negative integer that don't cause underflow when doubled
const int INF = 0x3f3f3f3f; //Big integer that don't cause overflow when doubled
//Shortened Methods
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
//loops
//Loops
#define f(i,n) for(int i=0;i<n;i++) //From 0 to n-1
#define rf(i,n) for(int i=n-1;i>=0;i--) //From n-1 to 0
#define F(i,a,b) for(int i=a;i<b;i++)
Expand All @@ -30,8 +30,8 @@ const int INF_N = 0xcfcfcfcf; //Min negative integer that don't cause underflow
#define rall(c) c.rbegin(), c.rend()
#define sz(x) ((int)(x).size())
//IO Optimization
#define __SpeedUP__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//Data Structures and Types
#define __FasterIO__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//Types
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
Expand All @@ -47,11 +47,12 @@ typedef std::pair<std::string, int> psi;
/* ################################################################################################## */

int main(){
// __SpeedUP__ //Uncomment for a faster runtime
//__FasterIO__ //Uncomment for improve runtime
//__log__ //Uncomment for redirect output to LOG.txt
string line;
while(getline(cin,line)){
cout << line << endl;
}

// __time__ //Uncomment for show runtime
//__time__ //Uncomment for show runtime
}
85 changes: 44 additions & 41 deletions templates/cpp/master.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ########################## Template available in: https://propi.dev/cp ########################## */
/* ######################## Template available in: https://propi.dev/cp ######################## */
//#pragma GCC optimize("-O3","-funroll-all-loops","-ffast-math") //Uncomment for a faster runtime
#include <bits/stdc++.h>
//Debug methods
Expand All @@ -8,12 +8,12 @@
#define _pair(x) {cout << #x << " = | " << "1st: " << x.first << " | " << "2nd: " << x.second << endl;} //Print pair
#define __time__ { auto duration = chrono::duration<double>( /* Show runtime */ \
std::chrono::high_resolution_clock::now() - beg); cout<<"Time: "<<duration.count()<<endl;}
#define __log__ { std::FILE* file = std::freopen("LOG.txt", "w", stdout); }
//Constants
const auto beg = std::chrono::high_resolution_clock::now(); //Begining of the program
const double PI = acos(-1); //PI
const double E = 1e-8; //Small Number (10^-8)
const int INF_P = 0x3f3f3f3f; //Max positive integer that don't cause overflow when doubled
const int INF_N = 0xcfcfcfcf; //Min negative integer that don't cause underflow when doubled
const int INF = 0x3f3f3f3f; //Big integer that don't cause overflow when doubled
const int MOD = 1e9+7; //Mod operations (prime number)
//Shortened Methods
#define pb push_back
Expand All @@ -24,15 +24,16 @@ const int MOD = 1e9+7; //Mod operations (prime number)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair <ll, ll> pll;
typedef std::vector<ll> vll;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<std::string> vs;
typedef std::vector<std::pair<int, int> > vpii;
typedef std::vector<std::pair<int, int>> vpii;
typedef std::map<int, int> mii;
typedef std::map<ll, ll> mll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<std::string, int> psi;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; //Min Heap
//loops
#define f(i,n) for(int i=0;i<n;i++) //From 0 to n-1
#define rf(i,n) for(int i=n-1;i>=0;i--) //From n-1 to 0
Expand All @@ -46,53 +47,55 @@ typedef std::pair<std::string, int> psi;
#define sz(x) ((int)(x).size())
#define ms(arr,val) memset(arr,val,sizeof(arr))
//IO Optimization
#define __SpeedUP__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// Custom Data Structs
#define __FasterIO__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//Templates
struct Graph { // Call like: Graph G(n); G.addEdge(u,v);
int n; vector<unordered_set<int>> adj;
Graph(int size) : n(size) { adj.resize(size); }
void addEdge(int u, int v) { adj[u].insert(v); adj[v].insert(u); }
void removeEdge(int u, int v) { adj[u].erase(v); adj[v].erase(u); }
void addEdge(int u, int v) { adj[u].insert(v); /* adj[v].insert(u); */ }
void removeEdge(int u, int v) { adj[u].erase(v); /* adj[v].erase(u); */ }
};
// HEADERS
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; //Min Heap
struct Graph; //Graph with adjacency list // vector <bool> visited(n,false);
template <template<typename...> class Container, typename T> // DFS: dbfs<stack,int>(G,v,visited)
void dbfs(Graph& G, int v, vector<bool>& visited); // BFS: dbfs<queue,int>(G,v,visited)

/* ################################################################################################## */


int main(){
// __SpeedUP__ //Uncomment for a faster runtime
string line;
while(getline(cin,line)){
cout << line << endl;
}

// __time__ //Uncomment for show runtime
}


/* ################################################################################################## */

template <template<typename...> class Container, typename T>
void dbfs(Graph& G, int v, vector<bool>& visited) {
Container<T> arr; arr.push(v); visited[v] = true;
template <template<typename...> class Container, typename T> // DFS: dbfs<stack,int>(G,v);
vector<int> dbfs(Graph& G, int v) { // BFS: dbfs<queue,int>(G,v);
vector<int> visited_order; //Order of graph traversal
vector<int> visited(G.n,INF); // Keep track of visited nodes
Container<T> arr; arr.push(v); visited[v] = v; // Starts at v

while (!arr.empty()) {
if constexpr(is_same<Container<T>, stack<typename Container<T>::value_type>>::value) {
v = arr.top(); // Use top if using std::stack
v = arr.top(); // top if std::stack
} else { v = arr.front(); } arr.pop(); // front if std::queue

cout << v << " "; // Do something with v
visited_order.pb(v); // DO SOMETHING WITH VISITED NODE

for (int w : G.adj[v]) { // For each unvisited neighbor of v
if (!visited[w]) {
arr.push(w); visited[w] = true;
if (visited[w] == INF) {
arr.push(w);
visited[w] = v; //Keep track of PARENT
// visited[w] = visited[v] + 1; //Keep track of DISTANCE
}
}
} cout << endl;
}

// _vec(visited_order) // Uncomment to print visited order
return visited;
}
vi backtrack(vi parent, int start, int end) { //Backtrack visited nodes to reconstruct a path
vi path; path.pb(end);
while (path.back() != start) { path.pb(parent[path.back()]); }
reverse(all(path)); return path;
}

/* ############################################################################################## */


/* ########################## Template available in: https://propi.dev/cp ########################## */
int main(){
//__FasterIO__ //Uncomment for improve runtime
//__log__ //Uncomment for redirect output to LOG.txt
string line;
while(getline(cin,line)){
cout << line << endl;
}

//__time__ //Uncomment for show runtime
}
11 changes: 6 additions & 5 deletions templates/cpp/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#define _pair(x) {cout << #x << " = | " << "1st: " << x.first << " | " << "2nd: " << x.second << endl;} //Print pair
#define __time__ { auto duration = chrono::duration<double>( /* Show runtime */ \
std::chrono::high_resolution_clock::now() - beg); cout<<"Time: "<<duration.count()<<endl;}
#define __log__ { std::FILE* file = std::freopen("LOG.txt", "w", stdout); }
//Constants
const auto beg = std::chrono::high_resolution_clock::now(); //Begining of the program
const double PI = acos(-1); //PI
const double E = 1e-8; //Small Number (10^-8)
const int INF_P = 0x3f3f3f3f; //Max positive integer that don't cause overflow when doubled
const int INF_N = 0xcfcfcfcf; //Min negative integer that don't cause underflow when doubled
const int INF = 0x3f3f3f3f; //Big integer that don't cause overflow when doubled
//IO Optimization
#define __SpeedUP__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define __FasterIO__ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//Loops
#define f(i,n) for(int i=0;i<n;i++) //For from 0 to n-1
#define rf(i,n) for(int i=n-1;i>=0;i--) //For from n-1 to 0
Expand All @@ -29,11 +29,12 @@ typedef std::pair <ll, ll> pll;
// ###################################################################################################### //

int main(){
// __SpeedUP__ //Uncomment for a faster runtime
//__FasterIO__ //Uncomment for improve runtime
//__log__ //Uncomment for redirect output to LOG.txt
string line;
while(getline(cin,line)){
cout << line << endl;
}

// __time__ //Uncomment for show runtime
//__time__ //Uncomment for show runtime
}
10 changes: 10 additions & 0 deletions templates/txt/basic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Powered by propi.dev ###
- Debug Methods:

- Constants:

- IO Optimization:

- Types:

### Powered by propi.dev ###
14 changes: 14 additions & 0 deletions templates/txt/complex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Powered by propi.dev ###
- Debug Methods:

- Constants:

- Shortened Methods:

- IO Optimization:

- Types:

- Loops:

### Powered by propi.dev ###
16 changes: 16 additions & 0 deletions templates/txt/master.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Powered by propi.dev ###
- Debug Methods:

- Constants:

- Shortened Methods:

- IO Optimization:

- Types:

- Loops:

- Templates:

### Powered by propi.dev ###
12 changes: 12 additions & 0 deletions templates/txt/standard.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Powered by propi.dev ###
- Debug Methods:

- Constants:

- IO Optimization:

- Types:

- Loops:

### Powered by propi.dev ###

0 comments on commit ca1ded9

Please sign in to comment.