Skip to content

Instantly share code, notes, and snippets.

View mikebsg01's full-sized avatar
📚
Creativity Is Intelligence Having Fun!

Michael Serrato mikebsg01

📚
Creativity Is Intelligence Having Fun!
View GitHub Profile
@mikebsg01
mikebsg01 / DFS.cpp
Last active November 27, 2017 10:00
Problem: Printing All Paths from a given source to a destination with Depth-First Search (DFS) Algorithm - By: Michael Serrato
/*
* ALGORITHM: Depth-First Search (DFS)
*
* @author Michael Serrato <mikebsg01@gmail.com>
*/
#include <iostream>
#include <algorithm>
#include <cctype>
#include <vector>
#include <deque>
@mikebsg01
mikebsg01 / BinarySearchTree.cpp
Last active November 19, 2017 12:32
Binary Search Tree (Data Structure) - By: Michael Serrato
/*
* PROGRAM: Binary Search Tree (Data Structure)
*
* @author Serrato Guerrero Michael Brandon <mikebsg01@gmail.com>
*/
#include <iostream>
#include <cstdlib>
using namespace std;
struct Nodo {
@mikebsg01
mikebsg01 / Open-HashTable.cpp
Last active November 19, 2017 12:32
Open Hash Table (Data Structure) - By: Michael Serrato
/*
* PROGRAM: OPEN HASH TABLE
*
* @author Serrato Guerrero Michael Brandon <mikebsg01@gmail.com>
*/
#include <stdio.h>
#include <malloc.h>
/* ------------------------------- E S T R U C T U R A S ------------------------------- */
struct pair {
@mikebsg01
mikebsg01 / MaxHeapSort.cpp
Last active November 19, 2017 12:31
Max-Heap Sort (Algorithm) - By: Michael Serrato
/*
* ALGORITHM: MAX-HEAP SORT
*
* @author Serrato Guerrero Michael Brandon <mikebsg01@gmail.com>
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
@mikebsg01
mikebsg01 / gist:3de3a056e8ba5eb9b700
Last active March 12, 2017 21:56
Entrenamiento IOI - Etapa #2 - Problem: Cellphone Typing - Judge: UVa - 21/11/2014 - Puntaje: 100% (AC) - Structure Solution: Trie (Tree).
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
int N;
double answer = 0;
struct NODO {
int prefix = 0;
NODO* hijos[30];
};
@mikebsg01
mikebsg01 / gist:22a0d1ef381b69f6223a
Last active March 12, 2017 21:55
Entrenamiento IOI - Etapa #2 - Problem: Long Hamming - Judge: omegaUp - 30/11/2014 - Puntaje: 100% (AC) - GCD + BIT (Theory mathematical + Binary Indexed Tree) - Complexity: O( 2 N 3 log 26 ).
#include <bits/stdc++.h>
#define pb push_back
#define MAXN 1000005
using namespace std;
typedef long long int lli;
lli N, M;
lli P, Q;
char A[MAXN];
char B[MAXN];
@mikebsg01
mikebsg01 / gist:926361bdaa38bc87ac47
Created December 1, 2014 06:17
Entrenamiento IOI - Etapa #2 - Problem: Digit Product - Judge: omegaUp - 30/11/2014 - Puntaje: 100% (AC) - Factorization + DP (Theory mathematical + Programming Dynamic).
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0);cin.tie(0)
#define sz size
using namespace std;
typedef long long int lli;
lli A, N;
string cad;
int digits[4005];
lli izq[40005];
lli der[40005];
@mikebsg01
mikebsg01 / gist:ef28519f1c3a9c2a356e
Last active March 12, 2017 21:53
Entrenamiento IOI - Etapa #2 - Problem: 4 Values whose Sum is 0 - Judge: ACM-ICPC Live Archive - 15/12/2014 - Puntaje: 100% (AC) - Meet In The Middle + Barrido.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define all(v) v.begin(), v.end()
#define ver(x) cout<<#x<<": "<<x<<"\n";
#define verP(x) cout<<#x<<": "<<*x<<"\n";
#define name(x) cout<<#x<<" \n";
#define MAXSZ 16000002
@mikebsg01
mikebsg01 / gist:7fb047a2cf2e719c13bd
Last active March 12, 2017 21:53
[ SOLUCIÓN MEJORADA ] - Entrenamiento IOI - Etapa #2 - Problem: 4 Values whose Sum is 0 - Judge: ACM-ICPC Live Archive - 15/12/2014 - Puntaje: 100% (AC) - Meet In The Middle + Barrido.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(v) v.begin(), v.end()
#define ver(x) cout<<#x<<": "<<x<<"\n";
#define verP(x) cout<<#x<<": "<<*x<<"\n";
#define name(x) cout<<#x<<" \n";
#define MAXSZ 16000002
using namespace std;
@mikebsg01
mikebsg01 / gist:fc554ae373988bef5aad
Last active March 12, 2017 21:52
Entrenamiento IOI - Etapa #2 - Problem: Industrial Nim - Judge: Codeforces - 09/01/2015 - Puntaje: 100% (AC) - (Theory Of Games).
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int N;
lli sum = 0;
lli x,m,y,a,b;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int i;