| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12998 | Palindrome Detection (hard version) |
|
| 12999 | Minesweeper |
|
Description
-
A palindrome is a word like “deed” or “level”, which remains the same when you spell it backward.
-
Write a program that inputs a word that terminates with a period '.' and determines whether or not the word is a palindrome.
-
Each input word's length is at least 1 and there is no maximum limit for its length. You must use DYNAMIC ARRAYs to do this task.
-
(Hint: You may define an array of size 20 to take the input first. If it's not enough, double its size to allow more input.)
Input
String of characters that terminates with a period '.'
Output
"a palindrome\n" or "not a palindrome\n"
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Write a program to input an H x W array of 0’s and 1’s where H and W are also user inputs. You may assume that both H and W are non-zero and at most 10. The array represents an H x W minefield so that a cell with a 1 (resp. 0) means the cell contains (does not contain) a bomb. Your program should print the minefield as follows:
- If a cell contains a bomb, print a ‘#’.
-
If a cell does not contain a bomb and is not adjacent to any bomb, print a ‘.’
-
Otherwise, print the number of neighboring bombs.
Input
-
The first input, H and W, is the size of the HxW array.
-
Next H lines will be the elements of the array.
Output
Output a HxW array
- If a cell contains a bomb, print a ‘#’.
- If a cell does not contain a bomb and is not adjacent to any bomb, print a ‘.’
- Otherwise, print the number of neighboring bombs.