WAGE - Wood, Axe and Grass
Danny has created a new civilization on a 2D grid. At the outset each grid location may be occupied by one of three life forms: Woods, Axe, or Grass. Each day, differing life forms occupying horizontally or vertically adjacent grid locations wage war. In each war, Woods always defeat Axe, Axe always defeat Grass, and Grass always defeat Woods. At the end of the day, the winner expands its territory to include the loser's grid position. The loser vacates the position.Determine the territory occupied by each life form after n days.
The first line of input contains t, the number of test cases. Each test case begins with three integers not greater than 100: r and c, the number of rows and columns in the grid, and n. The grid is represented by the r lines that follow, each with c characters. Each character in the grid is W, A, or G, indicating that it is occupied by Woods, Axe, or Grass respectively.
For each test case, print the grid as it appears at the end of the nth day.
3 3 1
3 4 2
Print no blanklines between cases as opposed to what samples imply. Kudos to Zukow for explaining the amiguous statement, I'm here to solve problems not guess my way through riddles.Last edit: 2019-03-02 15:06:53
easy implementation. Got AC with only 34 lines of code C++ :)
those who found difficult to understand
Easy one ;)
Accepted on first try. Simple question below comments really helped alot
simple ad-hoc :/
Could anybody help my with my program?
so much time wasted due to silly mistakes
No, that's incorrect.
|Cluster:||Cube (Intel G860)|
|Languages:||All except: ADA95 ASM32 ASM64 BASH CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO ICON ICK LUA NEM NICE OCAML PIKE PRLG-swi SCM qobi SCM guile ST TCL WHITESPACE|