Codigo-C.com.ar

Problemas y Soluciones en C y C++
Icono RSS Icono E-mail Icono Inicio
  • Problemas ACM - Volumen VII - Enunciados y Soluciones

    Publicado el 5 05America/Chicago Septiembre 05America/Chicago 2010 admin Sin comentarios aún ...

    Desde este artículo hay un link a los enunciados de los Problemas del Volumen VII:

  • Problemas ACM - Volumen VI - Enunciados y Soluciones

    Publicado el 20 20America/Chicago Agosto 20America/Chicago 2010 admin Sin comentarios aún ...

    Desde este artículo hay un link a los enunciados de los Problemas del Volumen VI:

  • Problemas ACM - Volumen V - Enunciados y Soluciones

    Publicado el 17 17America/Chicago Agosto 17America/Chicago 2010 admin Sin comentarios aún ...

    Desde este artículo hay un link a los enunciados de los Problemas del Volumen V:

  • Problemas ACM - Volumen IV - Enunciados y Soluciones

    Publicado el 19 19America/Chicago Julio 19America/Chicago 2010 admin Sin comentarios aún ...

    Desde este artículo hay un link a los enunciados de los Problemas del Volumen IV:

    • 400 - Unix ls: Enunciado
    • 401 - Palindromes: Enunciado
    • 402 - M*A*S*H: Enunciado
    • 406 - Prime Cuts: Enunciado
    • 408 - Uniform Generator: Enunciado
    • 409 - Excuses, Excuses!: Enunciado
    • 412 - Pi: Enunciado
    • 413 - Up and Down Sequences: Enunciado
    • 414 - Machined Surfaces: Enunciado
    • 417 - Word Index: Enunciado
    • 422 - Word-Search Wonder: Enunciado
    • 423 - MPI Maelstrom: Enunciado
    • 424 - Integer Inquiry: Enunciado
    • 436 - Arbitrage (II): Enunciado
    • 437 - The Tower of Babylon: Enunciado
    • 438 - The Circumference of the Circle: Enunciado
    • 439 - Knight Moves: Enunciado
    • 440 - Eeny Meeny Moo: Enunciado
    • 441 - Lotto: Enunciado
    • 442 - Matrix Chain Multiplication: Enunciado
    • 443 - Humble Numbers: Enunciado
    • 444 - Encoder and Decoder: Enunciado
    • 445 - Marvelous Mazes: Enunciado
    • 446 - Kibbles `n’ Bits `n’ Bits `n’ Bits: Enunciado
    • 448 - OOPS!: Enunciado
    • 450 - Little Black Book: Enunciado
    • 453 - Intersecting Circles: Enunciado
    • 455 - Periodic Strings: Enunciado
    • 457 - Linear Cellular Automata: Enunciado
    • 458 - The Decoder: Enunciado
    • 459 - Graph Connectivity: Enunciado
    • 460 - Overlapping Rectangles: Enunciado
    • 465 - Overflow: Enunciado
    • 466 - Mirror, Mirror: Enunciado
    • 469 - Wetlands of Florida: Enunciado
    • 473 - Raucous Rockers: Enunciado
    • 474 - Heads / Tails Probability: Enunciado
    • 476 - Points in Figures: Rectangles: Enunciado
    • 477 - Points in Figures: Rectangles and Circles: Enunciado
    • 478 - Points in Figures: Rectangles, Circles, and Triangles: Enunciado
    • 481 - What Goes Up: Enunciado
    • 482 - Permutation Arrays: Enunciado
    • 483 - Word Scramble: Enunciado
    • 484 - The Department of Redundancy Department: Enunciado
    • 485 - Pascal’s Triangle of Death: Enunciado
    • 486 - English-Number Translator: Enunciado
    • 488 - Triangle Wave: Enunciado
    • 489 - Hangman Judge: Enunciado
    • 490 - Rotating Sentences: Enunciado
    • 492 - Pig-Latin: Enunciado
    • 494 - Kindergarten Counting Game: Enunciado
    • 495 - Fibonacci Freeze: Enunciado
    • 496 - Simply Subsets: Enunciado
    • 497 - Strategic Defense Initiative: Enunciado
    • 498 - Polly the Polynomial: Enunciado
    • 499 - What’s The Frequency, Kenneth?: Enunciado
    • Problemas ACM - Volumen III - Enunciados y Soluciones

      Publicado el 26 26America/Chicago Junio 26America/Chicago 2010 admin Sin comentarios aún ...

      Desde este artículo hay un link a los enunciados de los Problemas del Volumen III:

      • 300 - Maya Calendar: Enunciado
      • 301 - Transportation: Enunciado
      • 302 - John’s trip: Enunciado
      • 303 - Pipe: Enunciado
      • 305 - Joseph: Enunciado
      • 306 - Cipher: Enunciado
      • 308 - Tin Cutter: Enunciado
      • 310 - L-System: Enunciado
      • 311 - Packets: Enunciado
      • 313 - Intervals: Enunciado
      • 314 - Robot: Enunciado
      • 315 - Network: Enunciado
      • 320 - Border: Enunciado
      • 324 - Factorial Frequencies: Enunciado
      • 325 - Identifying Legal Pascal Real Constants: Enunciado
      • 326 - Extrapolation using a Difference Table: Enunciado
      • 327 - Evaluating Simple C Expressions: Enunciado
      • 331 - Mapping the Swaps: Enunciado
      • 332 - Rational Numbers from Repeating Fractions: Enunciado
      • 333 - Recognizing Good ISBNs: Enunciado
      • 336 - A Node Too Far: Enunciado
      • 337 - Interpreting Control Sequences: Enunciado
      • 340 - Mastermind Hints: Enunciado
      • 341 - Non-Stop Travel: Enunciado
      • 343 - What Base Is This?: Enunciado
      • 344 - Roman Digititis: Enunciado
      • 347 - Run, Run, Runaround Numbers: Enunciado
      • 348 - Optimal Array Multiplication Sequence: Enunciado
      • 350 - Pseudo-Random Numbers: Enunciado
      • 352 - Seasonal War: Enunciado
      • 353 - Pesky Palindromes: Enunciado
      • 355 - The Bases are Loaded: Enunciado
      • 356 - Seasonal War: Enunciado
      • 357 - Let Me Count The Ways: Enunciado
      • 361 - Cops and Robbers: Enunciado
      • 362 - 18,000 Second: Enunciado
      • 369 - Combinations: Enunciado
      • 371 - Ackermann Functions: Enunciado
      • 374 - Big Mod: Enunciado
      • 377 - Cowculations: Enunciado
      • 374 - Big Mod: Enunciado
      • 378 - Intersecting Lines: Enunciado
      • 382 - Perfection: Enunciado
      • 383 - Shipping Routes: Enunciado
      • 384 - Slurpys: Enunciado
      • 386 - Perfect Cubes: Enunciado
      • 389 - Basically Speaking: Enunciado
      • 392 - Polynomial Showdown: Enunciado
      • 394 - Mapmaker: Enunciado
      • Problemas ACM - Volumen II - Enunciados y Soluciones

        Publicado el 28 28America/Chicago Mayo 28America/Chicago 2010 admin Sin comentarios aún ...

        Desde este artículo hay un link a los enunciados de los Problemas del Volumen II:

        • 200 - Rare Order: Enunciado
        • 201 - Squares: Enunciado
        • 202 - Repeating Decimals: Enunciado
        • 216 - Getting in Line: Enunciado
        • 218 - Moth Eradication: Enunciado
        • 227 - Puzzle: Enunciado
        • 231 - Testing the CATCHER: Enunciado
        • 232 - Crossword Answers: Enunciado
        • 253 - Cube Painting: Enunciado
        • 254 - Towers of Hanoi: Enunciado
        • 256 - Quirksome Squares: Enunciado
        • 259 - Software Allocation: Enunciado
        • 260 - Il Gioco dell’X: Enunciado
        • 263 - Number Chains: Enunciado
        • 264 - Count on Cantor: Enunciado
        • 270 - Lining Up: Enunciado
        • 271 - Simply Syntax: Enunciado
        • 272 - TeX Quotes: Enunciado
        • 275 - Expanding Fractions: Enunciado
        • 278 - Chess: Enunciado
        • 280 - Vertex: Enunciado
        • 288 - Arithmetic Operations With Large Integers: Enunciado
        • 290 - Palindroms: Enunciado
        • 291 - The House Of Santa Claus: Enunciado
        • 294 - Divisors: Enunciado
        • 297 - Quadtrees: Enunciado
        • 299 - Train Swapping: Enunciado
        • Problemas ACM - Volumen I - Enunciados y Soluciones

          Publicado el 21 21America/Chicago Mayo 21America/Chicago 2010 admin Sin comentarios aún ...

          Desde este artículo hay un link a los enunciados de los Problemas del Volumen I:

        • Ayudamos a Escuelas de Frontera.com!

          Publicado el 4 04America/Chicago Mayo 04America/Chicago 2010 admin Sin comentarios aún ...

          y vos también podés hacerlo….

          Te contamos porqué y como:

          Escuelas de Frontera.com es el sitio de la Asociación Hermano Sol Hermana Luna de Asís. Esta asociación tiene un blog donde podés conocer a la gente que la conforma y sacarte todas las dudas:

          http://escuelasdefrontera.blog.arnet.com.ar

          Brevemente, José Antonio Franco y mucha gente alrededor de él, armaron un Banco Permanente de Medicamentos Para Nuestra Puna Jujeña y Salteña, y se encargan de recolectar no sólo medicamente, sino muchas otras cosas, que son de inmensa utilidad para las escuelas (y los chicos en ellas!), en rincones tan hermosos como descuidados muchas veces, de nuestra querida Argentina.

          Desde nuestro sitio (www.codigo-c.com.ar) apoyamos la idea, y lo hacemos donando todos los ingresos que se generan desde las publicidades del programa Adsense de Google, que se pueden observar en las páginas del mismo.

          Vos también, si tenés un sitio web, podés hacerlo, sólo tenés que escribirnos y te enviamos el código que tenés que pegar en tu página, para que los clicks que hagan en dichos anuncios se transformen en ayuda monetaria para EscuelasdeFrontera.com.
          El código que te enviamos tiene el identificador que corresponde a la cuenta en Adsense, de la Fundación Hermano Sol, Hermana Luna de Asís, y todos los meses mostramos un detalle de como se generaron los ingresos de cada mes (hoy, Abril de 2009, recién estamos comenzando, pero tenemos la esperanza de que muchos sitios se sumen a esta iniciativa, y entre todos podamos hacer un aporte significativo).

          Desde ya muchas gracias!

          Daniel Ambort
          webmaster www.codigo-c.com.ar

        • Problema ACM 101 - The Blocks Problem

          Publicado el 23 23America/Chicago Marzo 23America/Chicago 2010 admin Sin comentarios aún ...

          Background

          Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm performed tasks involving the manipulation of blocks.

          In this problem you will model a simple block world under certain rules and constraints. Rather than determine how to achieve a specified state, you will “program” a robotic arm to respond to a limited set of commands.

          The Problem

          The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are n blocks on the table (numbered from 0 to n-1) with block bi adjacent to block bi+1 for all

          $0 \leq i < n-1$

          as shown in the diagram below:

          imagen problema The blocks problem

          imagen problema The blocks problem

          The valid commands for the robot arm that manipulates blocks are:

          • move a onto b:  where a and b are block numbers, puts block a onto block b after returning any blocks that are stacked on top of blocks a and b to their initial position
          • move a over b: where a and b are block numbers, puts block a onto the top of the stack containing block b, after returning any blocks that are stacked on top of block a to their initial positions.
          • pile a onto b: where a and b are block numbers, moves the pile of blocks consisting of block a, and any blocks that are stacked above block a, onto block b. All blocks on top of block b are moved to their initial positions prior to the pile taking place. The blocks stacked above block a retain their order when moved.
          • pile a over b: where a and b are block numbers, puts the pile of blocks consisting of block a, and any blocks that are stacked above block a, onto the top of the stack containing block b. The blocks stacked above block a retain their original order when moved.
          • quit: terminates manipulations in the block world.

          Any command in which a = b or in which a and b are in the same stack of blocks is an illegal command. All illegal commands should be ignored and should have no affect on the configuration of blocks.

          The Input

          The input begins with an integer n on a line by itself representing the number of blocks in the block world. You may assume that

          0 < n < 25.

          The number of blocks is followed by a sequence of block commands, one command per line. Your program should process all commands until the quit command is encountered.

          You may assume that all commands will be of the form specified above. There will be no syntactically incorrect commands.

          The Output

          The output should consist of the final state of the blocks world. Each original block position numbered i ( $0 \leq i < n$ where n is the number of blocks) should appear followed immediately by a colon. If there is at least a block on it, the colon must be followed by one space, followed by a list of blocks that appear stacked in that position with each block number separated from other block numbers by a space. Don’t put any trailing spaces on a line.

          There should be one line of output for each block position (i.e., n lines of output where n is the integer on the first line of input).

          Sample Input

          10
          move 9 onto 1
          move 8 over 1
          move 7 over 1
          move 6 over 1
          pile 8 over 6
          pile 8 over 5
          move 2 over 1
          move 4 over 9
          quit

          Sample Output

           0: 0
           1: 1 9 2 4
           2:
           3: 3
           4:
           5: 5 8 7 6
           6:
           7:
           8:
           9:



        • Problema ACM 10067 - Playing with wheels

          Publicado el 2 02America/Chicago Julio 02America/Chicago 2009 admin Sin comentarios aún ...

          Playing with Wheels

          Input: standard Input
          Output: standard output

          In this problem we will be considering a game played with four wheels. Digits ranging from 0 to 9 are printed consecutively (clockwise) on the periphery of each wheel. The topmost digits of the wheels form a four-digit integer. For example, in the following figure the wheels form the integer 8056. Each wheel has two buttons associated with it. Pressing the button marked with a left arrow rotates the wheel one digit in the clockwise direction and pressing the one marked with the right arrow rotates it by one digit in the opposite direction.

          playing with wheels acm problem

          playing with wheels acm problem

          The game starts with an initial configuration of the wheels. Say, in the initial configuration the topmost digits form the integer S1S2S3S4. You will be given some (say, n) forbidden configurations Fi1Fi2Fi3Fi4, (1 <= i <= n ) and a target configuration T1T2T3T4. Your job will be to write a program that can calculate the minimum number of button presses required to transform the initial configuration to the target configuration by never passing through a forbidden one.

          Input

          The first line of the input contains an integer N giving the number of test cases to follow.
          The first line of each test case contains the initial configuration of the wheels specified by 4 digits. Two consecutive digits are separated by a space. The next line contains the target configuration. The third line contains an integer n giving the number of forbidden configurations. Each of the following n lines contains a forbidden configuration.
          There is a blank line between two consecutive input sets.

          Output

          For each test case in the input print a line containing the minimum number of button presses required. If the target configuration is not reachable then print -1.

          Sample Input

          2
          8 0 5 6
          6 5 0 8
          5
          8 0 5 7
          8 0 4 7
          5 5 0 8
          7 5 0 8
          6 4 0 8

          0 0 0 0
          5 3 1 7
          8
          0 0 0 1
          0 0 0 9
          0 0 1 0
          0 0 9 0
          0 1 0 0
          0 9 0 0
          1 0 0 0
          9 0 0 0
          Sample Output
          14
          -1
          ______________________________________________________________________________________
          Rezaul Alam Chowdhury