Ուղարկել | Բոլոր լուծումները | Լավագույն լուծումները | Վերադառնալ ցուցակին |
ACM_0006 - KLINGON BATTLE BAGEL |
Two opponents play a game on a checkered field of size N×M. The first player places several shapes of "Klingon battle
bagel" spaceship in the field. The shape of the ship is a solid 3×3 square having a hole in the center (see Fig.). Ships
can touch the edges of the field and each other but cannot intersect.
The second player tries to find all the ships, firing at the cells of the field.
The second player has made K shots at different cells hitting the ships, and F shots at other cells that missed.
Write program to calculate the minimum and the maximum number of ships that can be located in the field.
Input
The number of rows N and the number of columns M (1 ≤ N, M ≤ 100000) of the playing field are given in the first line of the input file, separated with a space character.
The second line contains the number of hits H and the number of misses F (0 ≤ H, F ≤ N×M, 0 ≤ H+F ≤ N×M).
Output
Space-delimited values of the minimum and the maximum number of ships possibly located on the field.
Output "BAZINGA!" (without quotation marks) if no solution exists for the input data.
Example
№ |
stdin |
stdout |
1 |
7 7 1 1 |
1 4 |
2 |
3 3 9 0 |
BAZINGA! |
Ավելացրեց. | Հրանտ Հովհաննիսյան |
Ամսաթիվ. | 2013-12-02 |
Ժամանակի սահմանափակումը. | 1s |
Ծրագրի տեքստի սահմանափակումը. | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Լեզուներ. | Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE |
Աղբյուրը. | Central QF 2013.I |