Codigo-C.com.ar
Problemas y Soluciones en C y C++-
Problemas ACM - Volumen VII - Enunciados y Soluciones
Publicado el 5 05America/Chicago Septiembre 05America/Chicago 2010 Sin comentarios aún ...Desde este artículo hay un link a los enunciados de los Problemas del Volumen VII:
- 700 - Date Bugs: Enunciado
- 701 - Archaelogist’s Dilemma: Enunciado
- 702 - The Vindictive Coach: Enunciado
- 703 - Triple Ties: The Organizer’s Nightmare: Enunciado
- 705 - Slash Maze: Enunciado
- 707 - Robbery: Enunciado
- 709 - Formatting Text: Enunciado
- 711 - Dividing up: Enunciado
- 712 - S-Trees: Enunciado
- 713 - Adding Reversed Numbers: Enunciado
- 714 - Copying Books: Enunciado
- 718 - Skyscraper Floors: Enunciado
- 719 - Glass Beads: Enunciado
- 725 - Division: Enunciado
- 727 - Equation: Enunciado
- 729 - Hamming Distance Problem: Enunciado
- 737 - Gleaming the Cubes: Enunciado
- 739 - Soundex Indexing: Enunciado
- 740 - Baudot Data Communication Code: Enunciado
- 741 - Burrows Wheeler Decoder: Enunciado
- 748 - Exponentiation: Enunciado
- 750 - 8 Queens Chess Problem: Enunciado
- 753 - A Plug for Unix: Enunciado
- 755 - 487-3279: Enunciado
- 756 - Biorhythms: Enunciado
- 762 - We Ship Cheap: Enunciado
- 763 - Fibinary Numbers: Enunciado
- 784 - Maze Exploration: Enunciado
- 787 - Maximum Sub-sequence Product: Enunciado
- 793 - Network Connections: Enunciado
- 796 - Critical Links: Enunciado
-
Problemas ACM - Volumen VI - Enunciados y Soluciones
Publicado el 20 20America/Chicago Agosto 20America/Chicago 2010 Sin comentarios aún ...Desde este artículo hay un link a los enunciados de los Problemas del Volumen VI:
- 600 - A Duckpin Tournament: Enunciado
- 601 - The Path: Enunciado
- 602 - What Day Is It?: Enunciado
- 603 - Parking Lot: Enunciado
- 604 - The Boggle Game: Enunciado
- 607 - Scheduling Lectures: Enunciado
- 608 - Counterfeit Dollar: Enunciado
- 610 - Street Directions: Enunciado
- 612 - DNA Sorting: Enunciado
- 613 - Numbers that Count: Enunciado
- 615 - Is It A Tree: Enunciado
- 616 - Coconuts, Revisited: Enunciado
- 619 - Numerically Speaking: Enunciado
- 620 - Cellular Structure: Enunciado
- 621 - Secret Research: Enunciado
- 623 - 500!: Enunciado
- 624 - CD: Enunciado
- 628 - Passwords: Enunciado
- 634 - Polygon: Enunciado
- 636 - Squares: Enunciado
- 637 - Booklet Printing: Enunciado
- 639 - Don’t Get Rooked: Enunciado
- 640 - Self Numbers: Enunciado
- 641 - Do the Untwist: Enunciado
- 642 - Word Amalgamation: Enunciado
- 644 - Immediate Decodability: Enunciado
- 656 - Optimal Programs: Enunciado
- 657 - The Die is Cast: Enunciado
- 661 - Blowing Fuses: Enunciado
- 663 - Sorting Slides: Enunciado
- 670 - The Dog Task: Enunciado
- 673 - Parentheses Balance: Enunciado
- 674 - Coin Change: Enunciado
- 679 - Dropping Balls: Enunciado
- 681 - Convex Hull Finding: Enunciado
- 684 - Integral Determinant: Enunciado
- 686 - Goldbach’s Conjecture (II): Enunciado
- 694 - The Collatz Sequence: Enunciado
- 696 - How Many Knights: Enunciado
- 699 - The Falling Leaves: Enunciado
-
Problemas ACM - Volumen V - Enunciados y Soluciones
Publicado el 17 17America/Chicago Agosto 17America/Chicago 2010 Sin comentarios aún ...Desde este artículo hay un link a los enunciados de los Problemas del Volumen V:
- 507 - Jill Rides Again: Enunciado
- 514 - Rails: Enunciado
- 515 - King: Enunciado
- 516 - Prime Land: Enunciado
- 517 - Word: Enunciado
- 523 - Minimum Transport Cost: Enunciado
- 524 - Prime RIng Problem: Enunciado
- 530 - Binomial Showdown: Enunciado
- 531 - Compromise: Enunciado
- 532 - Dungeon Master: Enunciado
- 533 - Equation Solver: Enunciado
- 534 - Frogger: Enunciado
- 535 - Globetrotter: Enunciado
- 536 - Tree Recovery: Enunciado
- 537 - Artificial Intelligence?: Enunciado
- 539 - The Settlers of Catan: Enunciado
- 541 - Error Correction: Enunciado
- 542 - France ‘98: Enunciado
- 543 - Goldbach’s Conjecture: Enunciado
- 544 - Heavy Cargo: Enunciado
- 547 - DDF: Enunciado
- 555 - Bridge Hands: Enunciado
- 558 - Wormholes: Enunciado
- 562 - Dividing Coins: Enunciado
- 563 - Crimewave: Enunciado
- 565 - Pizza Anyone?: Enunciado
- 567 - Risk: Enunciado
- 568 - Just the Facts: Enunciado
- 571 - Jugs: Enunciado
- 572 - Oil Deposits: Enunciado
- 573 - The Snail: Enunciado
- 574 - Sum It Up: Enunciado
- 575 - Skew Binary: Enunciado
- 576 - Haiku Review: Enunciado
- 579 - ClockHands: Enunciado
- 580 - Critical Mass: Enunciado
- 583 - Prime Factors: Enunciado
- 585 - Triangles: Enunciado
- 587 - There’s Treasure Everywhere!: Enunciado
- 590 - Always on the Run: Enunciado
- 591 - Box of Bricks: Enunciado
- 594 - One Little, Two Little, Three Little Endians: Enunciado
-
Problemas ACM - Volumen IV - Enunciados y Soluciones
Publicado el 19 19America/Chicago Julio 19America/Chicago 2010 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 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 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 Sin comentarios aún ...Desde este artículo hay un link a los enunciados de los Problemas del Volumen I:
- 100 - The 3 n + 1 Problem: Enunciado
- 101 - The Blocks Problem: Enunciado
- 102 - Ecological Bin Packing: Enunciado
- 103 - Stacking Boxes: Enunciado
- 104 - Arbitrage: Enunciado
- 105 - The Skyline Problem: Enunciado
- 106 - Fermat vs. Pythagoras: Enunciado
- 107 - The Cat in the Hat: Enunciado
- 108 - Maximum Sum: Enunciado
- 109 - SCUD Busters: Enunciado
- 110 - Meta-Loopless Sorts: Enunciado
- 111 - History Grading: Enunciado
- 112 - Tree Summing: Enunciado
- 113 - Power of Cryptography: Enunciado
- 114 - Simulation Wizardry: Enunciado
- 115 - Climbing Trees: Enunciado
- 116 - Unidirectional TSP: Enunciado
- 117 - The Postal Worker Rings Once: Enunciado
- 118 - Mutant Flatworld Explorers: Enunciado
- 119 - Greedy Gift Givers: Enunciado
- 120 - Stacks of Flapjacks: Enunciado
- 121 - Pipe Fitters: Enunciado
- 122 - Trees on the level: Enunciado
- 123 - Searching Quickly: Enunciado
- 124 - Following Orders: Enunciado
- 125 - Numbering Paths: Enunciado
- 126 - The Errant Physicist: Enunciado
- 127 - Accordian Patience: Enunciado
- 128 - Software CRC: Enunciado
- 129 - Krypton Factor: Enunciado
- 130 - Roman Roulette: Enunciado
- 131 - The Psychic Poker Player: Enunciado
- 132 - Bumpy Objects: Enunciado
- 133 - The Dole Queue: Enunciado
- 134 - Loglan-A Logical Language: Enunciado
- 135 - No Rectangles: Enunciado
- 136 - Ugly Numbers: Enunciado
- 137 - Polygons: Enunciado
- 138 - Street Numbers: Enunciado
- 139 - Telephone Tangles: Enunciado
- 140 - Bandwidth: Enunciado
- 141 - The Spot Game: Enunciado
- 142 - Mouse Clicks: Enunciado
- 143 - Orchard Trees: Enunciado
- 144 - Student Grants: Enunciado
- 145 - Gondwanaland Telecom: Enunciado
- 146 - ID Codes: Enunciado
- 147 - Dollars: Enunciado
- 148 - Anagram Checker: Enunciado
- 151 - Power Crisis: Enunciado
- 152 - Tree’s a Crowd: Enunciado
- 153 - Permalex: Enunciado
- 154 - Recycling: Enunciado
- 155 - All Squares: Enunciado
- 156 - Ananagrams: Enunciado
- 159 - Word Crosses: Enunciado
- 160 - Factors and Factorials: Enunciado
- 161 - Traffic Lights: Enunciado
- 162 - Beggar My Neighbour: Enunciado
- 164 - String Computer: Enunciado
- 165 - Stamps: Enunciado
- 166 - Making Change: Enunciado
- 167 - Sultans Successors: Enunciado
- 168 - Theseus and the Minotaur: Enunciado
- 170 - Clock Patience: Enunciado
- 172 - Calculator Language: Enunciado
- 183 - Bit Maps: Enunciado
- 184 - Laser Lines: Enunciado
- 186 - Trip Routing: Enunciado
- 187 - Transaction Processing: Enunciado
- 188 - Perfect Hash: Enunciado
- 191 - Intersection: Enunciado
- 193 - Graph Coloring: Enunciado
- 195 - Anagram: Enunciado
- 196 - Spreadsheet: Enunciado
-
Ayudamos a Escuelas de Frontera.com!
Publicado el 4 04America/Chicago Mayo 04America/Chicago 2010 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 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

as shown in the diagram below:

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 (
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 Sin comentarios aún ...Playing with Wheels
Input: standard Input
Output: standard outputIn 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
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 80 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


