This file contains 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
// | |
// majority.cpp | |
// programas2 | |
// | |
// Created by Lucca Siaudzionis on 27/03/13. | |
// Copyright (c) 2013 Luccasiau. All rights reserved. | |
// | |
#include <cstdio> | |
#define MAXN 3000005 |
This file contains 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 <cstdio> | |
#define MAXN 1100 | |
int n, m, resp; | |
int pai[MAXN], peso[MAXN]; | |
int find(int x){ //funcao do Union-Find | |
This file contains 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 <cstdio> | |
#include <cstring> | |
#define MAXN 100010 | |
#define MAXS 1000010 | |
#define max(A,B) (A)>(B)?(A):(B) | |
int MAX = 1000001; | |
int bit[MAXS]; | |
void insere(int x){ |
This file contains 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 <cstdio> | |
#include <algorithm> | |
#define MAXT 100005 | |
using namespace std; | |
int main(){ | |
int n; | |
scanf("%d",&n); | |
int A[MAXT]; |
This file contains 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 <cmath> | |
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
//---------------------- | |
#define MAXN 100100 | |
typedef long long lint; | |
int n; |
This file contains 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 <queue> | |
#include <cstdio> | |
#include <vector> | |
#include <cstring> | |
#include <algorithm> | |
#define MAXN 50010 | |
using namespace std; | |
int nodes,edges; | |
int grau[MAXN]; |
This file contains 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 <cstdio> | |
#include <vector> | |
#include <cstring> | |
#include <algorithm> | |
#define MAXN 50010 | |
using namespace std; | |
int nodes; | |
int edges; | |
int size; |
This file contains 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
// | |
// competicao_de_chocolate.cpp | |
// programas2 | |
// | |
// Created by Lucca Siaudzionis on 29/04/14. | |
// Copyright (c) 2014 Luccasiau. All rights reserved. | |
// | |
#include <cstdio> | |
#define MAXN 1001010 |
This file contains 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
// componente[i] se trata da componente do vértice i | |
// inicialmente, componente[i] = -1 para todo vértice | |
// faremos a DFS como sendo uma função recursiva | |
// antes de chamar a DFS no primeiro nó, definimos sua componente | |
DFS(vértice X): | |
para todo V vizinho a X: | |
se (componente[V] == -1): | |
componente[V] = componente[X] | |
DFS(V) |
This file contains 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
// o código a seguir é uma BFS partindo do vértice X | |
// o array componente está inicializado para -1 em todas suas casas | |
fila.insere(X) | |
componente[X] := valor | |
enquanto (fila.tamanho > 0) faça: | |
//vamos trabalhar com o primeiro da fila | |
V = fila.frente |