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
#define MAX_V 100001 | |
int id = 0; | |
int L[MAX_V], R[MAX_V]; // [L, R] | |
vector<int> adj[MAX_V]; | |
int dfs(int cur) { | |
int i = ++id, cnt = 0; | |
L[cur] = i; | |
for (auto& nxt : adj[cur]) { |
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
#include <bits/stdc++.h> | |
using namespace std; | |
#define all(v) (v).begin(),(v).end() | |
struct seg { | |
int n; | |
vector<int> t; | |
void build(int sz) { |
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
#include <bits/stdc++.h> | |
using namespace std; | |
#define FOR(i, n) for(int i=0; i<(n); ++i) | |
typedef long long lld; | |
map<int, int> h1, h2; | |
int main() { |
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
#include <bits/stdc++.h> | |
using namespace std; | |
#define CONSO 0 | |
#define VOWEL 1 | |
#define COMBINE_C 2 | |
#define COMBINE_V 3 | |
bool isVowel[255]; | |
set<string> cVowel, cConso; |
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
bool binary_search(int arr[], int len, const int& key) { | |
int l = 0, r = len - 1; | |
while (l <= r) { | |
int mid = (l + r) / 2; | |
if (arr[mid] < key) | |
l = mid + 1; | |
else | |
r = mid - 1; | |
} | |
return a[l] == key; |
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
#include <cstdio> | |
// if you want to use STL, uncomment following includes: | |
// #include <vector> | |
// #include <algorithm> | |
// using namespace std; | |
// count "key" from array sized n | |
// if no key, print "NO" | |
int main() { | |
int n; |
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
template<typename T> | |
bool binary_search(T *arr, T *end, const T& x) { | |
return *lower_bound(arr, end, x) == x; | |
} |
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
// based on quick sort | |
template<typename T> | |
void sort(T *arr, T *end) { | |
int l = 0, r = (end - arr) - 1; | |
if (l >= r) return; | |
T mid = arr[(l + r) / 2]; | |
while (l <= r) { | |
while (arr[l] < mid) ++l; | |
while (mid < arr[r]) --r; | |
if (l <= r) { |
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
template<typename T> | |
class vector { | |
public: | |
vector(int capacity = 4) { | |
_a = new T[capacity](); | |
_cap = _size = capacity; | |
} | |
vector(int capacity, const T value) { | |
_a = new T[capacity](); | |
_cap = _size = capacity; |
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
# https://www.youtube.com/watch?v=Hx58twR_VY0 | |
NUMBERS = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twentyone", "twentytwo", "twentythree", "twentyfour", "twentyfive", "twentysix", "twentyseven", "twentyeight", "twentynine", "thirty", "thirtyone", "thirtytwo", "thirtythree", "thirtyfour", "thirtyfive", "thirtysix", "thirtyseven", "thirtyeight", "thirtynine", "forty", "fortyone", "fortytwo", "fortythree", "fortyfour", "fortyfive", "fortysix", "fortyseven", "fortyeight", "fortynine", "fifty", "fiftyone", "fiftytwo", "fiftythree", "fiftyfour", "fiftyfive", "fiftysix", "fiftyseven", "fiftyeight", "fiftynine", "sixty", "sixtyone", "sixtytwo", "sixtythree", "sixtyfour", "sixtyfive", "sixtysix", "sixtyseven", "sixtyeight", "sixtynine", "seventy", "seventyone", "seventytwo", "seventythree", "seventyfour", "seventyfive", "seventysix", "seventyseven", "seventyeig |