Skip to content

Instantly share code, notes, and snippets.

View Juanito98's full-sized avatar

Juan Carlos Sigler Priego Juanito98

View GitHub Profile
@Juanito98
Juanito98 / Number Theory.cpp
Last active June 5, 2017 00:35
Euclides extendido
#include <bits/stdc++.h>
#define lld long long int
using namespace std;
lld gcd(lld a, lld b, lld &x, lld &y) {
if(!b) {
x = 1; y = 0;
return a;
} else {
lld d = gcd(b, a % b, x, y);
@Juanito98
Juanito98 / Surveillance.cpp
Last active May 1, 2017 01:35
ACM-ICPC Live Archive 6780 - Surveillance
#include <bits/stdc++.h>
#define lld long long int
using namespace std;
const int MAXN = 2000002;
const int LOGN = 31;
int skip[MAXN][LOGN];
int d(pair < int, int > a, pair < int, int > b) {
return b.second - a.first + 1;
@Juanito98
Juanito98 / Query on a tree.cpp
Created April 18, 2017 01:01
SPOJ QTREE - Query on a tree. Heavy - Light Decomposition
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10002;
struct ura {
int a, b, c;
};
ura edges[MAXN];
struct node {
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 300002
using namespace std;
struct ura {
map < int, int > S;
int suma;
void insert(int x, int v) {
@Juanito98
Juanito98 / Counting substhreengs.cpp
Created February 20, 2017 19:16
ACM-ICPC Live Archive 6823 - Counting substhreengs
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define lld long long int
#define llf long double
using namespace std;
const int MAXN = 100002;
int c;
lld res[3];
@Juanito98
Juanito98 / Galaxy Collision.cpp
Last active February 20, 2017 19:18
ACM-ICPC Live Archive 6827 - Galaxy Collision
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define lld long long int
#define llf long double
using namespace std;
const int MAXN = 100002;
int n;
int padre[MAXN];
int color[MAXN];
@Juanito98
Juanito98 / Join Two Kingdoms.cpp
Last active February 20, 2017 19:17
UVa 12677 - Join two kingdoms
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define lld long long int
using namespace std;
const int MAXN = 100002;
struct bit {
lld tree[MAXN * 2];
void update(int pos, int v) {
@Juanito98
Juanito98 / Walls.cpp
Created February 4, 2017 06:47
IOI '00 Day 2, Problem 1.
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 300
using namespace std;
int n, m;
vector < int > pertenece[MAXN];
int pared[MAXN][MAXN];
int matriz[MAXN][MAXN];
@Juanito98
Juanito98 / Knights of the Round Table.cpp
Created January 30, 2017 02:17
ACM-ICPC Live Archive 6831. Knights of the Round Table
//#include <bits/stdc++.h>
#include <iostream>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 2000002
#define lld long long int
using namespace std;
#include <bits/stdc++.h>
#define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 50002
#define lld long long int
using namespace std;
int n, k;
lld D;
pair < int, int > arr[MAXN];