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 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

131/224

Solve/Submission

Ranking

# User Language Timing
01 Rana_EEE_DUET Cpp14 0.00s
02 joy25896 Cpp14 0.00s
03 Aman_khan Cpp14 0.00s
04 emrul Cpp14 0.00s
05 rayhan50001 Cpp14 0.00s
06 rafsandevs Cpp14 0.00s
07 Indro_BU Cpp14 0.00s
08 golapraj Cpp14 0.00s
09 maxhasan Cpp14 0.00s
10 The_Viper Cpp14 0.00s
11 gazi93 Cpp14 0.00s
12 jayed_al_hasan Cpp14 0.00s
13 gulzar Cpp14 0.00s
14 rezaul_karim Cpp14 0.00s
15 Nurul_CSE Cpp14 0.00s
16 sadia2427 Cpp14 0.00s
17 Dragon_162 Cpp14 0.00s
18 non_coder Cpp14 0.00s
19 nazmul_bzs Cpp14 0.00s
20 HM39 Cpp14 0.00s
21 jualahmed Cpp14 0.00s
22 Koushik54 Cpp14 0.00s
23 Mehedi07 Cpp14 0.00s
24 smriad Cpp14 0.00s
25 ayancse_98 Cpp14 0.00s
26 atqrhmn Cpp14 0.00s
27 Tajir Cpp14 0.00s
28 soumitro_cse1604114 Cpp14 0.00s
29 lolcoder Cpp14 0.00s
30 bpr10ry Cpp14 0.00s
31 MohammadShamim Cpp14 0.00s
32 1604099_ishtiaq Cpp14 0.00s
33 mh4746 Cpp14 0.00s
34 Nijhum1604125 Cpp14 0.00s
35 MUKTO1604100 Cpp14 0.00s
36 Sakif_1604124 Cpp14 0.00s
37 Mahadi024 Cpp14 0.00s
38 afzalul Cpp14 0.00s
39 noyonhossen Cpp14 0.00s
40 JAMEE Cpp14 0.00s
41 nahid101 Cpp14 0.00s
42 1604131 Cpp14 0.00s
43 gourob1604097 Cpp14 0.00s
44 1604110 Cpp14 0.00s
45 esha1604103 Cpp14 0.00s
46 Nasif Cpp14 0.00s
47 lightlessShadO Cpp14 0.00s
48 CSE1604084_Mahir Cpp14 0.00s
49 Sudipta_Nath Cpp14 0.00s
50 omar1604082 C 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support