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
/** | |
* La idea principal es utilizar union-find disjoint set | |
* Tener cuidado con la lectura. Usar getchar() para leer saltos de linea (\n) | |
* | |
* */ | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> | |
#include <queue> |
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
/** | |
Los puntos claves son usar gcd para reducir al maximo la fraccion sum/n | |
Para impresión se puede usar este tip: | |
c=cifras(n) | |
char b[50]="% d\n"; | |
b[1]=c+'0';//convertir int to char | |
printf(b,abs(sum)) | |
Asi se fuerza a ocupar c espacios la impresion del numero sum | |
**/ |
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
/** | |
La idea es representar como una lista de adjacencia el número (n)(el número n esta mapeado para ahorrar espacio) y sus aparaciones en el arreglo | |
eje: 1 5 8 9 5 4 5 | |
5: 2 5 7 | |
**/ | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> |
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
/** | |
La idea principal es representar la matriz como una lista de ayacencia. | |
Para hacer el transpuesta esun proceso ad-hoc | |
**/ | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> |
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
/** | |
Hay que tener cuidado con el formato de salida: | |
"...each value right justified in a field of width 3" (cada valor justificado en un campo de tamaño 3) | |
Y con la idea de que si se pierde la pared de la derecha y encontramos con pared de frente, | |
tiene prioridad encontrar pared girando a la derecha, antes que hacer el giro a a la izquierda | |
**/ |
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
/** | |
La de idea de solución es considerar que el número de vertices (v) menos aruistas (e) nos da el númeo de árboles (incluyendo los "acorns") | |
Y además los vertices que no tengan ninguna arista son considerados como "acorns" | |
**/ | |
#include <iostream> | |
#include <cstdio> | |
#include <map> | |
#include <bitset> |
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
/** | |
La idea de solucion es hacer una simulacion con las tres estructuras | |
**/ | |
#include <iostream> | |
#include <cstdio> | |
#include <stack> | |
#include <queue> | |
using namespace std; |
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
/** | |
La idea de solución es tomar siempre los valoresminimos disponibles. | |
Para ello utilizamos una cola de prioridad(minima) y simplemente, | |
simulamos el proceso | |
**/ | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> |
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 <iostream> | |
#include <cmath> | |
#include <algorithm> | |
#include <queue> | |
#include <stack> | |
#include <sstream> | |
#include <map> | |
#include <set> | |
using namespace std; |
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
/** | |
Concepto clave de la solución: avanzar 279 días (periodo de gestación) a partir de la fecha que nos dan | |
Tener cuidado con los años bisiestos | |
**/ | |
#include <cstdio> | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> |