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
| // Codigo por Lidiane Gomes | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int fat(int n) | |
| { | |
| if(n == 1) | |
| return 1; | |
| return n * fat(n - 1); |
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
| // Solucao Intermediário Semana 59 - Anagramas | |
| // Thiago Mota | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int maxn = 100010; | |
| map<string, int> freq; | |
| string str[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
| // Solucao Informatica Avancado Semana 59 | |
| // Thiago Mota | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int maxn = 100010; | |
| int f[maxn]; | |
| int n; |
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
| // (n) é o tamanho do vetor | |
| // (log_n) é o log na base 2 de n | |
| // (v) é o vetor | |
| void computa() { | |
| // Caso inicial (tamanho 1, j = 0) | |
| for (int i = 1; i <= n; i++) | |
| tab[i][0] = v[i]; // Intervalo [i, i] | |
| for (int j = 1; j <= log_n; j++) { |
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
| // (n) é o tamanho do vetor | |
| // (v) é o vetor | |
| int flog(int x) { // Calcula a parte inteira do log2 de x em O(1) ( para int ) | |
| return 31 - __builtin_clz(x); | |
| } | |
| int flog(long long x) { // Calcula a parte inteira do log2 de x em O(1) ( para long long ) | |
| return 63 - __builtin_clzll(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
| for(int mask = 0;mask < (1<<N); ++mask){ | |
| for(int i = 0;i < (1<<N); ++i){ | |
| if((mask&i) == i){ | |
| F[mask] += A[i]; | |
| } | |
| } | |
| } |
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
| // iterando em todas as mask's | |
| for (int mask = 0; mask < (1<<n); mask++){ | |
| F[mask] = A[0]; | |
| // iterando em todos os subconjuntos de mask | |
| for(int i = mask; i > 0; i = (i-1) & mask){ | |
| F[mask] += A[i]; | |
| } | |
| } |
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
| for(int mask = 0; mask < (1<<N); ++mask){ | |
| dp[mask][-1] = A[mask]; // Tratar o caso com o bit -1 separadamente, para simplificar nao iremos tratar o caso separado. | |
| for(int i = 0;i < N; ++i){ | |
| if(mask & (1<<i)) | |
| dp[mask][i] = dp[mask][i-1] + dp[mask^(1<<i)][i-1]; | |
| else | |
| dp[mask][i] = dp[mask][i-1]; | |
| } | |
| F[mask] = dp[mask][N-1]; | |
| } |
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
| #include <bits/stdc++.h> | |
| #define maxn 100010 | |
| using namespace std; | |
| vector<int> grafo[maxn]; | |
| int n, m; | |
| int c, mark[maxn]; | |
| void dfs(int u) { // DFS para marcar todos os caras na componente | |
| for(int i = 0; i < (int)grafo[u].size(); i++) { |
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
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int maxn = 510; | |
| int v[maxn]; | |
| int main() { | |
| ios::sync_with_stdio(false), cin.tie(0); // OTIMIZAÇÃO DO CIN/COUT | |
| int n; | |
| cin >> n; |