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.
lunes, 24 de septiembre de 2012
lunes, 10 de septiembre de 2012
Concurso Fes Acatlán
Les dejo el enlace para que vean los detalles: http://cimac.acatlan.unam.mx/?m=concurso#
quien este interesado en participar comuniquelo a los demas.
Raggedy, Raggedy Regional 2011 North America Mid Atlantic
Consider the problem of laying out text in lines of a fixed maximum width L (a.k.a., ``line filling'').
If you do a poor job,
the ends of the lines are unnecessarily
ragged - like
this paragraph. Now,
by convention, we allow the last line of a paragraph to be arbitrarily ragged. We don't mind if that final line contains just a few characters, but we expect the earlier lines to be of approximately uniform length, filling up the column in which we are setting the text.
See if we care.could be laid out in L = 6 like this:
See if we care.That layout is, arguably, not as visually pleasing as
See if we care.Define a ``word'' as any sequence of non-whitespace characters bounded by a line start or end or by a blank. The legal ``whitespace characters'' in this problem are blanks and the line terminator characters.
Given a sequence of N words of width w1, w2,..., wN, and a maximum line width L, with the guarantee that for all i, wi
Then we can define the raggedness of a line containing words i though j as
Input
Input will consist of one or more datasets.Each dataset begins with a line containing one integer, L, denoting the maximum line width (not counting line terminator characters). You are guaranteed that 0 < L
The remainder of the dataset consists of up to 250 lines containing a paragraph of text, terminated by an empty line. Paragraphs may contain from 1 to 500 words, where a word is any consecutive sequence of non-whitespace characters.
No line of text will contain a word of length greater than L.
Output
Print each paragraph laid out optimally as described above. After each paragraph print a line containing ``==='' (three equal signs).If there is more than one way to fill a paragraph with the optimal raggedness, any such layout may be printed.
Sample Input
6 See if we care. 25 Raggedy, raggedy are we. Just as raggedy as raggedy can be. We don't get nothin' for our labor. So raggedy, raggedy are we. - P Seeger 0
Sample Output
See if we care. === Raggedy, raggedy are we. Just as raggedy as raggedy can be. We don't get nothin' for our labor. So raggedy, raggedy are we. - P Seeger ===
jueves, 2 de agosto de 2012
Problema de la UVA 12318
Digital Roulette
John is developing a videogame that allows players to bet in a wall roulette. Players may bet for integer numbers
from 0 to N, for some N| Digital Roulette |
Of course, the roulette behaves digitally. As a matter of fact, John designed its way to choose a value in the interval 0..N (the result of spinning the roulette) with a digital trigger that moves the roulette with a force that depends on an integer value x randomly chosen in the interval 0..M, where M
It is clear that some result values may be produced by different chosen force values. Also, depending on the mechanism parameters, some numbers in the roulette may be not attainable regardless of the force value. For example, if N = 7, M = 5 and P(x) = x2 + 1, the mechanism can generate only three different results:
John wants to know how many different result values may be attained by his mechanism. Can you help him?
Input
There are several cases to analyze. Each case is described by three lines:- The first line contains two non-negative integer numbers N and M, separated by a blank (
1
N
107, 0
M
105).
- The second line contains an integer k, the grad of the polynomial P (
0
k
10).
- The third line contains k + 1 integers
a0, a1,..., ak separated by blanks, indicating the integer coefficients
that define the polynomial P, i.e.,
P(x) = akxk + ... + a1x + a0. You can assume that
0
ai
N for each 0
i
k. If k > 0 then you may assume that ak
0.
Output
For each case, print one line indicating how many different numbers are attainable by John's mechanism.Sample Input
7 5 2 1 0 1 99 10 0 5 99 10 1 5 25 99 10 1 3 29 99 10 2 3 29 31 0 0
Sample Output
3 1 4 11 10
jueves, 21 de junio de 2012
Duda libreria iostream
que saben acerca del uso de la libreria iostream?
del hecho de que deba ponerse.h o no para declarla?
que se deba poner
using namespace std; o std:: antes de cada objeto o funcion?
Yo intente usar << de cout, sin poner using namespace std; y no lo compilaba bien codeblocks
lunes, 18 de junio de 2012
Problema de esta semana: COJ 1500 an express taxi
Descripción
Especificación de entrada
Especificación de salida
Ejemplo de entrada
12 21 31 40 49 58 69 79 90 101 15
Ejemplo de salida
3 31 6 58 6 58 147
sábado, 2 de junio de 2012
miércoles, 30 de mayo de 2012
Resultados del concurso de hoy en el Politécnico
sábado, 26 de mayo de 2012
Teoria para revisar
les dejo los links de 2 libros que me recomendaron:
http://acm.cs.buap.mx/downloads/Programming_Challenges.pdf
http://acm.uva.es/p/Art_of_Programming_Contest_SE_for_uva.pdf
viernes, 25 de mayo de 2012
Concurso de programación en el Politécnico
http://148.204.58.221/capituloacm/?c=contenidos/portada.htm
Pues ¡a prepararnos!
domingo, 20 de mayo de 2012
No habrá curso del sábado 26 de mayo
domingo, 13 de mayo de 2012
Problema para la tercera semana de mayo
| Problem
E: Dora Trip |
Time
limit: 3 seconds
|
Nobita is in great trouble. Today he failed to hand in his homework again, so he was heavily punished at school. Learning that, his mother gets furious, and therefore assigns him many tasks to do - to buy vegetables at the market, to collect a parcel at the post office and a lot more. Nobita certainly does not want to see his teacher on his way, nor would he like to meet Jyian, the tough bully. As usual, he asks Doraemon for help.
"Oh no!" cried Doraemon. "My everywhere door is broken, and my small propellers have all run out of batteries..." Well, that means Nobita has got to go without Doraemon's magic tools. "Ah, I still have this. It may well be useful." From his 4th-dimensional pocket, Doraemon takes out a map of their living area. He then marks on it the places where Nobita has to visit by asterisks ('*'), and where Jyian or his teacher may appear by crosses ('X'). Now Nobita's job is simple - he has to find the shortest route, through which he would not visit any of the 'crosses', and he could finish the maximum number of the jobs (if not all) given by mum. What he needs is just a computer program that works out the path...
Imagine that you are Nobita. Write the program.
Input
The input file contains no more than 20 test cases. The details of each set are given as follows:The first line of each case contains two integers r and c (1 <= r, c <= 20), which are the number of rows and columns of the map respectively. The next r lines, each with c characters, give the map itself. For each character, a space `` '' stands for an open space; a hash mark ``#'' stands for an obstructing wall; the capital letter ``S'' stands for the position of Nobita's house, which is where his journey is to start and end; the capital letter ``X'' stands for a dangerous place; and an asterisk ``*'' stands for a place he has to visit. The perimeter of the map is always closed, i.e., there is no way to get out from the coordinate of the ``S''. The number of places that Nobita has to visit is at most 10.
The input file is terminated by a null case where r = c = 0. This case should not be processed.
Output
For each test case, if Nobita cannot visit any target places at all, just print the line "Stay home!". Otherwise, your program should output the lexicographically smallest shortest path so that the number of target places that Nobita visits is maximized. Use the letters 'N', 'S', 'E' and 'W' to denote north, south, east and west respectively. Note that by 'north' we mean facing upwards. You can be sure that the length of a correct output path will never exceed 200.Sample Input5 5 ##### # S# # XX# # *# ##### 5 5 ##### #* X# ###X# #S *# ##### 5 5 ##### #S X# # X# # #*# ##### 0 0 |
Sample OutputWWSSEEWWNNEE EEWW Stay home! |
Problemsetter: Mak Yan Kei
domingo, 6 de mayo de 2012
Un problema de caribbean online judge
Descripción
The network cables joining computers (servers) belong to different companies. A new anti-monopoly legislation prevents any company from owning more than two cables from each server. Furthermore, to avoid wasting resources, there is also a law specifying that the cable system owned by any single company cannot be redundant, i.e., removal of any of the cables will disconnect some two previously connected servers. Since the companies buy and sell the cables all the time, it is quite difficult to enforce these regulations. Your task is to write a program that does so.
Especificación de entrada
The following M lines describe the cables. Each of them contains three integers Sj1 , Sj2 and Kj , separated by spaces, giving the numbers of the servers Sj1 and Sj2 (1 <= Sj1 < Sj2 <= N) joined by that cable and the number of the company Kj (1 <= Kj <= C) initially owning the cable. For each pair of servers, there is at most one cable joining them. The initial state satisfies the regulations, i.e., each company owns at most two cables incident with each server, and the system of cables owned by a single company has no cycles.
Finally, each of the next T lines contains integers Si1 , Si2 and Ki describing one transaction in which the company Ki (1 <= Ki <= C) tries to buy a cable between servers Si1 and Si2 (1 <= Si1 < Si2 <= N).
The last instance is followed by a line containing four zeros.
Especificación de salida
- "No such cable." if the pair of servers is not joined by a cable,
- "Already owned." if the cable is already owned by the company Ki,
- "Forbidden: monopoly." if the company Ki already owns two cables at Si1 or Si2,
- "Forbidden: redundant." if Ki owns at most one cable at each of Si1 and Si2, but granting the ownership would create a cycle of cables owned by Ki,
- "Sold." if none of the above restrictions apply. In this case, the ownership of the cable between Si1 and Si2 changes to Ki for the purpose of further transactions.
- Print one empty line after each instance.
Ejemplo de entrada
4 5 3 5 1 2 1 2 3 1 3 4 2 1 4 2 1 3 3 1 2 3 1 2 3 1 4 3 2 3 3 2 4 3 2 1 1 1 1 2 1 1 2 1 0 0 0 0
Ejemplo de salida
Sold. Already owned. Forbidden: monopoly. Forbidden: redundant. No such cable. Already owned.
Sugerencia(s)
| Origen | 2010/2011 ACM-ICPC Central Europe Regional Contest |
| Adicionado por | ymondelo20 |
| Fecha de adición | 2012-04-22 |
| Tiempo límite (ms) | 10000 |
| Memoria límite (kb) | 130000 |
| Salida límite (mb) | 64 |
| Tamaño límite (bytes) | 30000 |
| Languages activados | C C# C++ Java Pascal Perl PHP Python Ruby Text |
domingo, 29 de abril de 2012
Problema para la primer semana de mayo
Buscaminas Reloaded
Karelov III 2007Tiempo: 1 segundo
Si encuentras un cuadro con un espacio vacío un número es impreso dentro de ese cuadro diciéndote cuántas minas son adyacentes a ese espacio vacío.
Un buen día te topaste con un juego de buscaminas con unicamente 2 filas y con N columnas.
Decidiste aventurarte un poco y seleccionaste todos los cuadrados de una de las filas, y como estabas de suerte, ninguno de los cuadrados de la fila resultó tener minas.
Sin embargo, en dicha fila aparecieron muchos números indicando cuántas minas había adyacentes a cada cuadro(todas las minas resultaron estar en la otra fila).
Problema
Dados los números que aparecieron en la fila que seleccionaste, determina en qué lugares de la otra fila debe haber minas.Entrada
La primera línea contendrá un número entero 1≤N≤200, la segunda línea contendrá unicamente N dígitos(números del 1 al 9) sin espacios representando el contenido de los cuadrados de la fila que seleccionaste.Salida
Deberá contener una sola línea con N caracteres, cada caracter deberá ser un '.' si no hay mina en su posición correspondiente o un '*' si la hay. Se garantiza que siempre habrá una y solo una solución posible.Ejemplo
|
|
Consideraciones
Se garantiza que siempre habrá solamente una solución posible, además 1≤N≤200.sábado, 28 de abril de 2012
Carta de Apoyo
|
Evento
|
Lugar y fecha de realización
|
Lugar obtenido
|
|
ACM-ICPC
México Occidente y Pacífico
|
24 de septiembre de 2011
|
16° lugar-50 equipos
|
|
ACM-ICPC ITAM
(Examen de preparación)
|
15 de
octubre de 2011
ITAM
|
2° lugar-23 equipos
|
|
2° Concurso Nacional de
Programación en Software Libre
|
20 de
octubre de 2011
3°
Congreso Nacional de Tecnología Computacional e Informática (FES Acatlán)
|
3° lugar-20 equipos
|
|
ACM ICPC
México y Centroamérica
|
5 de noviembre de 2011
ITESO, Guadalajara
|
7° lugar 160 equipos
|
domingo, 22 de abril de 2012
Problema de la semana: 714 UVA Online Judge
Copying Books
Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and after several months he finished its copy. One of the most famous scribers lived in the 15th century and his name was Xaverius Endricus Remius Ontius Xendrianus (Xerox). Anyway, the work was very annoying and boring. And the only way to speed it up was to hire more scribers.| Copying Books |
Once upon a time, there was a theater ensemble that wanted to play famous Antique Tragedies. The scripts of these plays were divided into many books and actors needed more copies of them, of course. So they hired many scribers to make copies of these books. Imagine you have m books (numbered
Input
The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly two lines. At the first line, there are two integers m and k,Output
For each case, print exactly one line. The line must contain the input successionIf there is more than one solution, print the one that minimizes the work assigned to the first scriber, then to the second scriber etc. But each scriber must be assigned at least one book.
Sample Input
2 9 3 100 200 300 400 500 600 700 800 900 5 4 100 100 100 100 100
Sample Output
100 200 300 400 500 / 600 700 / 800 900 100 / 100 / 100 / 100 100
Miguel A. Revilla
2000-02-15
lunes, 16 de abril de 2012
¡¡Va el de esta semana!!
Yo intente resolverlo, segun creo mi programa lo resuelve, pero no el tiempo indicado.
C | Consistent Verdicts |
Input
Output
Sample Input | Output for Sample Input |
231 12 24 421 15 5 | Case 1: 4Case 2: 2 |
"Problemas semanales"
Considero que seria apropiado que resolvieramos por lo menos un problema a la semana, ademas de los que hacemos el sabado, por lo que les propongo lo siguiente:
Cada lunes, antes de las 10:00 p.m, Alain o Yo propondremos un problema a resolver (no es mucho pedir que revisen el blog una vez a la semana). Si lo resuelven publiquen su respuesta, si no pongan sus avances, dudas, etc. que sera enriquecedor al grupo.
sábado, 14 de abril de 2012
Problem B: Ultra-QuickSort
In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. For the input sequence9 1 0 5 4 ,Ultra-QuickSort produces the output
0 1 4 5 9 .Your task is to determine how many swap operations Ultra-QuickSort needs to perform in order to sort a given input sequence.
The input contains several test cases. Every test case begins with a line that contains a single integer n < 500,000 -- the length of the input sequence. Each of the the following n lines contains a single integer 0 ≤ a[i] ≤ 999,999,999, the i-th input sequence element. Input is terminated by a sequence of length n = 0. This sequence must not be processed.
For every input sequence, your program prints a single line containing an integer number op, the minimum number of swap operations necessary to sort the given input sequence.
sábado, 24 de marzo de 2012
Solución al problema Moscas de la Omi Training Gate
#include<stdio.h>
long n[60002],i,s,k,x,y,m;
int main(){
scanf("%ld",&k);
for(i=0;i<k;i++){
scanf("%ld %ld",&x,&y);
n[x]++;
n[y]--;
}
for(i=0;i<60001;i++){
s=s+n[i];
if(s>m)
m=s;
}
x=0;
y=0;
printf("%ld\n",m);
for(i=0;i<60001;i++){
if(s==m&&s+n[i]<m)
printf("%ld %ld ",x,i);
if(s<m&&s+n[i]==m)
x=i;
s=s+n[i];
}
}
miércoles, 21 de marzo de 2012
Concurso de la UVA Online Judge
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=13&page=show_contest&contest=296
Yo intente hacer el C y el H, pero mis algoritmos no eran eficientes, por lo que no me los aceptaron. Se los dejo como comentarios.
Si a alguien se le ocurre como resolverlos, o algun otro de la UVA, posteen su codigo.
sábado, 17 de marzo de 2012
Un número redivisible es aquel que es divisible entre su número de divisores positivos. Por ejemplo 1(1 divisor), 12(6 divisores) y 9(3 divisores) pero no 7(2 divisores) ni 16(5 divisores)
Escribe un programa que dados dos enteros l y h, diga cuántos números refactorizables hay entre l y h, inclusive.







