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
// Reference: http://codeforces.com/blog/entry/18051 | |
template <typename T> | |
struct SegmentTree { | |
int n; | |
T* t; | |
T zero_val; | |
inline T operation(T a, T b) | |
{ | |
return max(a, b); |
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 <stdio.h> | |
#include <string.h> | |
#define N 1000000000000000000ULL | |
short is_prime(unsigned long long n) | |
{ | |
unsigned long long i; | |
if (n < 2) return 0; | |
if (n == 2) return 1; |
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
let get_server_time = () => { | |
let req = new XMLHttpRequest(); | |
req.open("GET", document.location, false); | |
req.send(null); | |
let date = new Date(req.getResponseHeader("Date")); | |
return date.getTime(); | |
} |
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
# Ignore all but files for competitive programming | |
* | |
!.gitignore | |
!*.cc | |
!*.txt | |
!*.cpp | |
!*/ | |
!Makefile |
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
\documentclass{article} | |
\usepackage[spanish]{babel} | |
\selectlanguage{spanish} | |
\usepackage[utf8]{inputenc} | |
\setlength{\parindent}{0pt} | |
\usepackage{amsfonts} | |
\usepackage{mathtools} | |
\usepackage{amsmath} | |
\usepackage{cancel} | |
\begin{document} |
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 <cmath> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
ld factorial_digit_count(ld n) | |
{ | |
// log(ab) = log(a) + log(b) |
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 itertools, math | |
def dist(a, b): | |
# 2d distance | |
dx = a[0] - b[0] | |
dy = a[1] - b[1] | |
return math.sqrt(dx*dx + dy*dy) | |
def valid_triangle(t): | |
# Check if triangle is valid (area > 0) |
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; | |
struct DisjointSet { | |
vector<int> parent; | |
vector<int> size; | |
}; |
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
// Use N <= 30 (good luck to calculate that) | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cmath> | |
using namespace std; | |
// bits values for bit arrays: | |
// 1 = free | |
// 0 = used |