DCP-32: The Grid Back to All Problems

Beginner Beginners Problems > Ad-hoc


A grid system is divided in rows and columns. You can consider it like a 2D array or you can consider it like a graph paper. Please check the following picture. ![grid][1] For this problem we will consider the grid is numbered from lower left corner of the grid. For example in the picture above, the lower left point is (0, 0) and the upper right corner is (6, 6). We have a starting point at (2, 1) and a destination point at (6, 6). In a grid system someone can only move in 4 directions – left, right, up and down. In this problem we need to find out what is the minimum number of moves required to go from starting point to destination point for various input set of starting point and destination point. Input: ------ First line of the input will consist of an integer which represent the test case **T (0 < T<= 30)**. Each test case contains 4 non-negative integers X1, Y1 and X2, Y2. Here X1, Y1 denotes the starting point and X2, Y2 denotes the destination point. You can assume all 4 integers will be less than or equal to 100. Output: ------- For each test case first print the test case number as “**Case X: Y**” where **X** is the test case number and Y is an integer denoting the minimum number of moves required to reach the destination from the starting point. Sample Input ------------ 3 2 1 6 6 0 0 9 9 12 6 99 0 Sample Output ------------- Case 1: 9 Case 2: 18 Case 3: 93 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/3176fdee-3665-c4ac-9d97-08d2e2bb9137_f3ca0db18df946ad872c92333023ee16_W267xH312.png


Problem Setter:

MD. Jalal Uddin

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C/C++ 1.00
Java 2.00
C# 2.00
PHP 2.00

Problem Stats

55/95

Solve/Submission

Ranking

# User Language Timing
01 ishrafislam2727 Cpp 0.00s
02 Rana_EEE_DUET Cpp 0.00s
03 joy25896 Cpp 0.00s
04 Aman_khan Cpp 0.00s
05 emrul Cpp 0.00s
06 rayhan50001 Cpp 0.00s
07 rafsandevs Cpp 0.00s
08 Indro_BU Cpp 0.00s
09 golapraj Cpp 0.00s
10 maxhasan Cpp 0.00s
11 The_Viper Cpp 0.00s
12 gazi93 Cpp 0.00s
13 jayed_al_hasan Cpp 0.00s
14 mahbub07 Cpp 0.01s
15 terminator_c Cpp 0.02s
16 jalal PHP 0.03s
17 NEUBAkash Cpp 0.07s
18 NEUBsajid Cpp 0.07s
19 anis Cpp 0.07s
20 chinmoysaha Cpp 0.07s
21 mahrahat Cpp 0.07s
22 marineCoder Cpp 0.08s
23 haasib Cpp 0.08s
24 askfarid Cpp 0.08s
25 Monira_Heya Cpp 0.08s
26 Dinar Cpp 0.08s
27 SkSaber Cpp 0.08s
28 anwar3606 Cpp 0.19s
29 sk_roy Cpp 0.21s
30 monsurmp Cpp 0.23s
31 Ashish_Deb Cpp 0.23s
32 Pankaj Cpp 0.24s
33 tariqiitju Cpp 0.39s
34 ArifKhanShubro Cpp 0.39s
35 dip_BRUR Cpp 0.40s
36 Ratnadeep24 Cpp 0.47s
37 Sabyasachi Cpp 0.48s
38 murad_al_wajed Cpp 0.48s
39 njrafi Cpp 0.49s
40 7Mahfuz Cpp 0.49s
41 showmic Cpp 0.49s
42 Sagor Cpp 0.49s
43 anowar1112 Cpp 0.50s
44 mdtameemkhan Cpp 0.51s
45 rana_cse Cpp 0.52s
46 sajal_khan Cpp 0.56s
47 Khalidprithy Cpp 0.60s
48 Shahadet Cpp 0.63s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support