This file contains hidden or 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
| // 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; |
This file contains hidden or 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
| // 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; |
This file contains hidden or 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
| // 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; |
This file contains hidden or 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
| // 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{ |
This file contains hidden or 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
| // 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){ |
This file contains hidden or 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
| // 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){ |
This file contains hidden or 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
| // Ivan Carvalho | |
| // Tráfego - Seletiva IOI - OBI 2014 | |
| #include <bits/stdc++.h> | |
| #define MAXN 50010 | |
| using namespace std; | |
| typedef pair<int,int> ii; | |
| struct aresta{ | |
| int alvo,d,g,r; | |
| }; | |
| int N,M; |
This file contains hidden or 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
| // Ivan Carvalho | |
| // Desvio de Rua - Maratona de Programação 2011 | |
| #include <bits/stdc++.h> | |
| #define MAXN 1001 | |
| using namespace std; | |
| vector<int> grafo[MAXN],transposto[MAXN],bidirecional[MAXN],tipo[MAXN]; | |
| int processado[MAXN],n,m,pai[MAXN],conjuntos,iteracao,hapontes; | |
| int dfs_low[MAXN],dfs_num[MAXN],dfs_parent[MAXN],pontosdearticulacao[MAXN],dfsNumberCounter,dfsRoot,dfsRootChildren; | |
| int find(int x){ | |
| if(x == pai[x]) return x; |
This file contains hidden or 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
| // Ivan Carvalho | |
| // Fila - Fase 2 Programação Nível 2 - OBI 2015 | |
| // O(n*log(n)) | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef struct node* pnode; | |
| struct node{ | |
| int prior,size,puro,maximo; | |
| pnode l,r; | |
| node(int puro) : l(NULL),r(NULL),puro(puro),maximo(puro),size(1), prior(rand()) {} |
This file contains hidden or 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
| // Ivan Carvalho | |
| // Código Reverso - Seletiva IOI - OBI 2013 | |
| // Alternative solution : O(n*lg(n)) | |
| #include <bits/stdc++.h> | |
| typedef struct node* pnode; | |
| const int MAXN = 500010; | |
| int entrada[MAXN],resposta[MAXN],N; | |
| struct node{ | |
| int key,prior,size; | |
| pnode l,r; |