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

66/113

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 gulzar Cpp 0.00s
15 rezaul_karim Cpp 0.00s
16 Nurul_CSE Cpp 0.00s
17 sadia2427 Cpp 0.00s
18 SakibAlamin Cpp 0.00s
19 Hasan_Masud Cpp 0.00s
20 non_coder Cpp 0.00s
21 giash_uddin Cpp 0.01s
22 deder Cpp 0.01s
23 mahbub07 Cpp 0.01s
24 terminator_c Cpp 0.02s
25 mhsjaber CSharp 0.03s
26 jalal PHP 0.03s
27 NEUBAkash Cpp 0.07s
28 NEUBsajid Cpp 0.07s
29 anis Cpp 0.07s
30 chinmoysaha Cpp 0.07s
31 mahrahat Cpp 0.07s
32 marineCoder Cpp 0.08s
33 haasib Cpp 0.08s
34 askfarid Cpp 0.08s
35 Monira_Heya Cpp 0.08s
36 Dinar Cpp 0.08s
37 SkSaber Cpp 0.08s
38 anwar3606 Cpp 0.19s
39 sk_roy Cpp 0.21s
40 monsurmp Cpp 0.23s
41 Ashish_Deb Cpp 0.23s
42 Pankaj Cpp 0.24s
43 tariqiitju Cpp 0.39s
44 ArifKhanShubro Cpp 0.39s
45 dip_BRUR Cpp 0.40s
46 Ratnadeep24 Cpp 0.47s
47 Sabyasachi Cpp 0.48s
48 murad_al_wajed Cpp 0.48s
49 njrafi Cpp 0.49s
50 7Mahfuz Cpp 0.49s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support