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 | |
| // Árvore- Seletiva IOI - OBI 2017 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int MAXN = 5*1e5 + 10; | |
| const int MAXL = 20; | |
| vector<int> grafo[MAXN],esq,dir,val; | |
| int ancestral[MAXN][MAXL],raiz[MAXN],n,q,segPtr,valor[MAXN],nivel[MAXN]; | |
| void utilidade(){ | |
| esq.push_back(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 | |
| // Caminhos- Seletiva IOI - OBI 2017 | |
| #include <bits/stdc++.h> | |
| #define MT make_tuple | |
| using namespace std; | |
| typedef long long ll; | |
| typedef tuple<ll,ll,ll> trinca; | |
| typedef pair<ll,ll> ii; | |
| const int MAXN = 2*1e4; | |
| vector<ii> grafo[MAXN]; |
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 | |
| // Seleção - Seletiva IOI - OBI 2017 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long ll; | |
| const int MAXN = 2*1e6 + 10; | |
| int A[MAXN],B[MAXN],soma[MAXN],N; | |
| ll K; | |
| int ax,bx,cx,mx,ay,by,cy,my; | |
| int func(int val){ |
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 | |
| // Dominó - Seletiva IOI - OBI 2013 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int MAXN = 1e4 + 10; | |
| int m[MAXN][3]; | |
| int dp[MAXN][2][2][2]; | |
| int N; | |
| int solve(int pos,int a1,int a2,int a3){ | |
| if(pos > N + 1) return 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 | |
| // Serrote - Seletiva IOI - OBI 2015 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long ll; | |
| const int MAXN = 1e3 + 10; | |
| const ll MOD = 1e9 + 7; | |
| ll dp[MAXN][MAXN],n,k; | |
| ll solve(ll tam,ll dentes){ | |
| if(tam == 3){ |
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 | |
| // Robô - Seletiva IOI - OBI 2014 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int MAXN = 1e5 + 10; | |
| const int INF = 1e9; | |
| int X,Y,seg[4*MAXN],lazy[4*MAXN],L[MAXN],R[MAXN]; | |
| void propagate(int pos,int left,int right){ | |
| if(lazy[pos] == 0) return; | |
| seg[pos] = lazy[pos]; |
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 | |
| // Binária - Seletiva IOI - OBI 2015 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long ll; | |
| const int MAXN = 101; | |
| const ll MOD = 1e9 + 7; | |
| ll dp[MAXN][MAXN]; | |
| ll binomial[MAXN][MAXN]; | |
| ll N,K,H,entrada[MAXN]; |
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 | |
| // Permutação - Seletiva IOI - OBI 2014 | |
| #include <bits/stdc++.h> | |
| #define gc getchar_unlocked | |
| inline void print(int n){ | |
| char buf[11]; | |
| buf[10] = ' '; | |
| int i = 9; | |
| while (n){ | |
| buf[i--] = n % 10 + '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 | |
| // Risco - Seletiva IOI - OBI 2014 | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int gcd(int a,int b){ | |
| if(a < b) swap(a,b); | |
| if(b == 0) return a; | |
| return gcd(b,a%b); | |
| } | |
| int main(){ |
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 | |
| // Taxa - Fase 3 Programação Nível 2 - OBI 2017 | |
| // O(N^3) | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int MAXN = 401; | |
| const int INF = 1e9; | |
| double fator; | |
| int dp[MAXN][MAXN],acumulada[MAXN],vetor[MAXN],total,resp,n; | |
| int calcula(int i,int j){ |