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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
template <typename type> | |
struct Comp { | |
Comp(type val) : _val(val) {} | |
bool operator() (const pair<type, vector<type>> & vec) const | |
{ |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
template<typename type> | |
class HeapTree { | |
private: | |
type max(type a, type b) { return a > b ? a : b; } | |
type min(type a, type b) { return a > b ? b : a; } |
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 type> | |
class HeapTree { | |
private: | |
type max(type a, type b) { return a > b ? a : b; } | |
type min(type a, type b) { return a > b ? b : a; } | |
vector<type> m_ele, M_ele; | |
size_t e_size, t_size; | |
pair<type,type> qquery(size_t node, size_t begin, size_t end, size_t first, size_t second) | |
{ | |
if (end < first || begin > second) |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
template<typename type> | |
class IndexTree { | |
private: | |
std::vector<type> elements; |
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
import re | |
test = input() | |
for i in range(test): | |
str = raw_input() | |
result=re.match("[A-F]?A+F+C+$[A-F]?",str) | |
if(result == None): | |
print("Good") | |
else: | |
print("Infected!") |
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<regex> | |
#include<iostream> | |
#include<string> | |
using namespace std; | |
int main(int argc, char ** argv) | |
{ | |
int test; cin >> test; | |
while (test--) | |
{ | |
string str; cin >> str; |
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
//INF Should not interfere Process | |
#define SEG_INF 0 | |
#include <vector> | |
#include <iterator> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; |
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
// | |
// kruskal.h | |
// | |
// kruskal algorithm by greedy | |
// | |
// INPUT: vector (directed, weighted graph) | |
// | |
// OUTPUT: minimum spanning tree | |
// | |
// Time: O(ElogV) |
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
// | |
// trie.h | |
// | |
// trie struct for string search | |
// | |
// INPUT: vector<string> (keys) | |
// | |
// OUTPUT: if string in keys | |
// | |
// Time: O(M) |
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
// | |
// topologicalSort.h | |
// | |
// TopologicalSort | |
// | |
// INPUT: vector | |
// | |
// OUTPUT: if directed acycilc graph return DAG; | |
// | |
// Time: theta(n+m) |