El grupo de Programación Competitiva Pu++ esta formado por alumnos de varias licenciaturas de la F. Ciencias (Abierto a la Comunidad de CU) con el principal objetivo de participar en concursos ACM. En este blog se encuentra algo de Teoria y Problemas con los que anteriormente hemos trabajado.
viernes, 8 de febrero de 2013
Comandos principales en la consola de Windows
Introducción
En los sistemas operativos de la familia Microsoft Windows la consola de comandos es llamada
Símbolo del Sistema (Command Prompt). Es una aplicación interpréte de comandos. Para acceder a él
podemos teclear “cmd” en el espacio de búsqueda del menú inicio y dar clic en el ejecutable, o ir a
Accesorios, donde aparece como Símbolo del Sistema. El programa soporta una amplia lista de
comandos que es ampliada con la instalación de software. Provee completado automático de comandos
y rutas de directorios, así como un historial de las últimas entradas tecleadas, búsqueda de ocurrencias
de palabras en archivos de texto, entre otras funciones.
Comandos principales
Los siguientes comandos son de gran utilidad, y al igual que la gran mayoría de los comandos en CMD,
soportan una gran cantidad de opciones y modos de uso (con ayuda del comando help se puede
averiguar un poco sobre esto). Cabe mencionar que para comandos CMD no distingue el uso de
minúsculas o mayúsculas.
DIR: Muestra una lista de archivos y subdirectorios en un directorio.
CD: Muestra el nombre del directorio actual o cambia a otro directorio.
Ejemplos
Para acceder al directorio raíz podemos teclear “cd \”
Si queremos volver una carpeta atrás usamos “cd ..”
Para acceder a una subcarpeta “cd nombre_1”
Si queremos acceder a una dirección más compleja usamos “cd nombre_1\nombre_2\nombre_3”
donde nombre_i es el nombre de la correspondiente carpeta en la dirección (la cantidad es arbitraria, es
decir, tenemos “cd Ruta”).
Para cambiar de unidad usamos “D:” donde D es el nombre de la unidad (aquí no usamos cd)
COPY Copia uno o más archivos en otra ubicación.
Ejemplos
Para crear una copia en la misma carpeta usamos “copy archivo.ext archivo_2.ext”
Para copiar un archivo a otra carpeta “copy archivo.ext “Ruta/archivo_2.ext”” donde es
indispensable el uso de comillas al señalar la dirección de destino.
DEL Elimina uno o más archivos
Ejemplo
Para borrar un archivo usamos “del archivo.ext”
EXIT Sale del programa CMD.EXE (interfaz de comandos).
FIND Busca una cadena de texto en uno o más archivos.
Ejemplo
Para ver las ocurrencias de una palabra en un texto usamos “find “palabra” texto.txt”
HELP Proporciona información de ayuda para los comandos de Windows.
Ejemplo
Para obtener una descripción de un comando tecleamos “help comando”
MD Crea un directorio.
Ejemplo
Para crear una carpeta “md Carpeta_1”
MOVE Mueve uno o más archivos de un directorio a otro en la
misma unidad.
RENAME Cambia el nombre de uno o más archivos.
TREE Muestra las subcarpetas en diagrama de árbol.
Uso de comodines
Al igual que en otros interpretes de comandos, es posible hacer uso de los llamados comodines en
CMD con el fin de aplicar ciertos comandos a conjuntos determinados de archivos, entre otras
opciones. Estos pueden emplearse con cualquier comando que emplee un nombre de archivo.
El caracter ? marca un caracter arbitrario. Por ejemplo, podemos usar “dir ???.cpp” para listar
todos los archivos con terminación cpp cuyo nombre tenga tres caracteres.
Por otra parte, empleamos * para marcar una cadena arbitraria de caracteres. Por ejemplo,
usamos “dir ???.*” para listar todos los archivos cuyo nombre tiene tres caracteres y con cualquier
extensión, o “dir *.cpp” para todos los archivos con terminación cpp.
Compilando en CMD
Para compilar código en C o C++ en CMD es necesario tener instalado un compilador (el sistema
operativo no lo trae por defecto). Por lo común, para compilar en C++ la sintaxis es la siguiente:
“g++ Archivo.cpp -o Archivo” donde la ultima cadena será el nombre del ejecutable creado (puede
tener otro nombre). Para compilar en C usualmente solo hace falta cambiar g++ por gcc.
Para emplear un ejecutable simplemente tecleamos “start Archivo.exe”
Referencias
http://en.wikipedia.org/wiki/Command_Prompt
http://ss64.com/nt/
http://www.taringa.net/posts/info/5851293/comandos-para-cmd-_simbolo-del-sistema_.html
miércoles, 6 de febrero de 2013
Concurso Bitwise
Les dejo el link del concurso que se realizara en linea el domingo:
http://www.bitwise.iitkgp.ernet.in/enigma/home
http://www.bitwise.iitkgp.ernet.in/enigma/home
Problema A del Regional
Hola, seguro recordaran este problema que no nos salio.
Abajo les dejo mi solucion.
A mining company extracts terbium, a rare metal used for constructing lightweight magnets, from river sand. They mine the Long River at N mining points, each of them identified by its distance from the river source. At each mining point, a relatively small but highly valued heap of mineral ore is extracted from the river.
To collect the mineral ore, the company regroups the N produced heaps into a smaller number of K heaps, each located at one of the initial mining points. The newly formed heaps are then collected by trucks.
To regroup the N heaps, they use a barge, which in practice can carry any amount of mineral ore because it is very large. The barge starts at the river source and can only travel downriver, so the heap produced at a mining point X can be taken to a mining point Y only if Y > X. Each heap is moved completely to another mining point, or not moved at all. The cost of moving a heap of weight W from a mining point X to a mining point Y is W x (Y - X). The total cost of the regrouping is the sum of the costs for each heap movement. Notice that a heap which is not moved has no influence on the total cost.
Given the values for N and K, the N mining points, and the weight of the heap each mining point produced, write a program that calculates the minimum total cost to regroup the N initial heaps into K heaps.
K < N
1000). Each of the next N lines describes one of the initial heaps with two integers X and W
indicating that the mining point X produced a heap of weight W (
1
X, W
106). Within each test
case the heaps are given in strictly ascending order considering their mining points.
Abajo les dejo mi solucion.
A mining company extracts terbium, a rare metal used for constructing lightweight magnets, from river sand. They mine the Long River at N mining points, each of them identified by its distance from the river source. At each mining point, a relatively small but highly valued heap of mineral ore is extracted from the river.
To collect the mineral ore, the company regroups the N produced heaps into a smaller number of K heaps, each located at one of the initial mining points. The newly formed heaps are then collected by trucks.
To regroup the N heaps, they use a barge, which in practice can carry any amount of mineral ore because it is very large. The barge starts at the river source and can only travel downriver, so the heap produced at a mining point X can be taken to a mining point Y only if Y > X. Each heap is moved completely to another mining point, or not moved at all. The cost of moving a heap of weight W from a mining point X to a mining point Y is W x (Y - X). The total cost of the regrouping is the sum of the costs for each heap movement. Notice that a heap which is not moved has no influence on the total cost.
Given the values for N and K, the N mining points, and the weight of the heap each mining point produced, write a program that calculates the minimum total cost to regroup the N initial heaps into K heaps.
Input
Each test case is described using several lines. The first line contains two integers N and K denoting respectively the number of initial heaps and the desired number of heaps after regrouping ( 1Sample Output
For each test case output a line with an integer representing the minimum total cost to regroup the N initial heaps into K heaps.Sample Input
3 1 20 1 30 1 40 1 3 1 11 3 12 2 13 1 6 2 10 15 12 17 16 18 18 13 30 10 32 1 6 3 10 15 12 17 16 18 18 13 30 10 32 1
Sample Output
30 8 278 86
Suscribirse a:
Entradas (Atom)