DCP-383: Knights Back to All Problems

Medium Game Theory > Observations/Pattern finding


Given an **n x m** chessboard. At location **(x,y)** (x is the row number and y is the column number) a white Knight is placed. You have to put minimum number of black Knights in the chessboard so that white knight can not move. If white knight just do a single move, one of your black knights can capture that knights in the next move. Those who are not familiar with chess knights , note chess knight can attack and move 8 position in the board as shown in the picture below. ![enter image description here][1] Input: ------ Input starts with an integer **T (1<=2000)**, denoting the number of test cases. Each case contains four integer **n,m ,x,y(4≤n,m≤1000 and 1≤x≤n and 1≤y≤m)** which described above. Output: ------- For each test case output one line Like **"Case X: Y"** without any quote where X is the case number and Y is the answer of the problem. Sample Input ------------ 1 10 10 5 5 Sample Output ------------- Case 1: 4 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/cd7a81ce-be03-c539-25d7-08d4c47e8c13_d177dee451aa4be2a188df0c037037d9_W553xH554.jpg


Problem Setter:

Suman Bhadra

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

5/20

Solve/Submission

Ranking

# User Language Timing
01 feodorv C 0.00s
02 BishalG Cpp 0.11s
03 mahbubcseju Cpp 0.32s
04 MRoy Cpp 0.58s
05 Morass Cpp14 0.81s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support