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

83/136

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 Dragon_162 Cpp 0.00s
19 non_coder Cpp 0.00s
20 nazmul_bzs Cpp 0.00s
21 HM39 Cpp 0.00s
22 jualahmed Cpp 0.00s
23 Koushik54 Cpp 0.00s
24 Mehedi07 Cpp 0.00s
25 smriad Cpp 0.00s
26 ayancse_98 Cpp 0.00s
27 atqrhmn Cpp 0.00s
28 Tajir Cpp 0.00s
29 soumitro_cse1604114 Cpp 0.00s
30 lolcoder Cpp 0.00s
31 bpr10ry Cpp 0.00s
32 MohammadShamim Cpp 0.00s
33 mahbub07 Cpp 0.01s
34 Saimum_140128 Cpp 0.01s
35 giash_uddin Cpp 0.01s
36 Aizen Cpp 0.01s
37 deder Cpp 0.01s
38 terminator_c Cpp 0.02s
39 mhmbd CSharp 0.02s
40 mhsjaber CSharp 0.03s
41 ririyad CSharp 0.03s
42 jalal PHP 0.03s
43 NEUBAkash Cpp 0.07s
44 NEUBsajid Cpp 0.07s
45 anis Cpp 0.07s
46 chinmoysaha Cpp 0.07s
47 mahrahat Cpp 0.07s
48 marineCoder Cpp 0.08s
49 haasib Cpp 0.08s
50 askfarid Cpp 0.08s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support