Skip to content

Instantly share code, notes, and snippets.

@IvanIsCoding
IvanIsCoding / parallel.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2007
// Ivan Carvalho
// Paralelogramo - Seletiva IOI - OBI 2007
// O(n^2 * log(n))
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
map<ii, map<double,int> > tab;
map<ii,int > special;
map<ii,int> freq;
int X[1001],Y[1001];
@IvanIsCoding
IvanIsCoding / tatu.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Tatu - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
#define MAXN 261
#define INF 1010
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
int matriz[MAXN][MAXN],acumulada[MAXN][MAXN],linear[MAXN];
@IvanIsCoding
IvanIsCoding / cantores.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Cantores - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 100010
#define MP make_pair
#define F first
#define S second
using namespace std;
typedef pair<char,char> cc;
typedef pair<cc,cc> c4;
@IvanIsCoding
IvanIsCoding / passeio.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Passeio - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef struct node* pnode;
typedef vector<ll>::iterator ite;
const ll MAXN = 1e5 + 10;
@IvanIsCoding
IvanIsCoding / frequencia.cpp
Last active July 11, 2017 15:23
Solução OBI 2014
// Ivan Carvalho
// Frequência - Fase 2 Programação Nível 2 - OBI 2014
// O(r*n*log(n))
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef pair<int,int> ii;
typedef struct node* pnode;
const int MAXN = 1e5 + 10;
const int MAXR = 51;
@IvanIsCoding
IvanIsCoding / ciclovias.cpp
Last active July 11, 2017 15:23
Solução OBI 2016
// Ivan Carvalho
// Ciclovias - Fase 2 Programação Nível 2 - OBI 2016
// O(m*log(n))
#include <bits/stdc++.h>
using namespace std;
typedef struct node* pnode;
const int MAXN = 1e5 + 10;
struct node{
int val;
pnode l,r;
@IvanIsCoding
IvanIsCoding / intervalo_treap.cpp
Last active July 11, 2017 15:23
Seletiva IOI 2014
// Ivan Carvalho
// Intervalo - Seletiva IOI - OBI 2014
// Alternative solution : O(n*lg(n))
#include <bits/stdc++.h>
using namespace std;
typedef struct node* pnode;
typedef long long ll;
struct node{
pnode l,r;
ll puro,total;
@IvanIsCoding
IvanIsCoding / cachecol.cpp
Last active July 11, 2017 15:23
Solução OBI 2013
// Ivan Carvalho
// Cachecol da Vovó Vitória - Fase 2 Programação Nível 2 - OBI 2013
// O(log(n))
#include <bits/stdc++.h>
#define REP(A,B) for(long long A=0;A<B;A++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll MAXK = 2;
typedef struct matrix{
@IvanIsCoding
IvanIsCoding / catalogo.cpp
Last active July 11, 2017 15:23
Solução OBI 2013
// Ivan Carvalho
// Catálogo de Músicas - Fase 1 Programação Nível 2 - OBI 2013
// O(n*log(n))
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3*1e5 + 10;
int ponteiro,N,n,tam[MAXN],filhos[MAXN],nivel[MAXN],total,resp;
set<int> grafo[MAXN];
map<string,int> conversao;
void dfs1(int x){
@IvanIsCoding
IvanIsCoding / simulador.cpp
Last active July 11, 2017 15:24
Solução OBI 2009
// Ivan Carvalho
// Simulador - Fase 2 Programação Nível 2 - OBI 2009
// O(M^2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct range{
ll ini,fim;
ll A,B;
range(ll _A,ll _B,ll add = 0){