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
r(i, j) = (L - w(i, j))2
Write a program to read paragraphs of text and to lay them out in a
way that no line contains more than L characters, for a specified
L, and so that you minimize the total raggedness added up over all
lines except the last one. (The final line of a paragraph can be
arbitrarily shorter then the lines above it.) Line terminator
characters are not counted as part of the line width.
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 ===
Suscribirse a:
Entradas (Atom)
