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 separated by a space. 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




# User Language Timing
01 shawon100 Cpp 0.00s
02 subhashis_cse Cpp 0.00s
03 Nazmul_WUB Cpp 0.00s
04 Rana_EEE_DUET Cpp14 0.00s
05 emrul Cpp14 0.00s
06 Biprodas Cpp14 0.00s
07 gazi93 Cpp14 0.00s
08 atqrhmn Cpp14 0.00s
09 joy25896 Cpp14 0.00s
10 shafayet_hossain Cpp 0.00s
11 The_Viper Cpp14 0.00s
12 Aman_khan Cpp14 0.00s
13 maxhasan Cpp14 0.00s
14 rayhan50001 Cpp14 0.00s
15 wizard Cpp 0.00s
16 non_coder Cpp14 0.00s
17 rezaul_karim Cpp14 0.00s
18 afzalul Cpp14 0.00s
19 Nurul_CSE Cpp14 0.00s
20 Indro_BU Cpp14 0.00s
21 Tanvirh Cpp 0.00s
22 feodorv C 0.00s
23 neel71 C 0.00s
24 leenaiitju Cpp 0.00s
25 gulzar Cpp14 0.00s
26 Mehedi07 Cpp14 0.00s
27 jualahmed Cpp14 0.00s
28 rafsandevs Cpp14 0.00s
29 Sayma_COU Cpp 0.00s
30 golapraj Cpp14 0.00s
31 MohammadShamim Cpp14 0.00s
32 sadia2427 Cpp14 0.00s
33 SakibAlamin Cpp14 0.00s
34 nazmul_bzs Cpp14 0.00s
35 DynamicOvi Cpp 0.00s
36 mh4746 Cpp14 0.00s
37 HM39 Cpp14 0.00s
38 Koushik54 Cpp14 0.00s
39 _dipu Cpp14 0.00s
40 smriad Cpp14 0.00s
41 Mahadi024 Cpp14 0.00s
42 lolcoder Cpp14 0.00s
43 milon019 Cpp 0.00s
44 noyonhossen Cpp14 0.00s
45 sumaiya710 C 0.00s
46 Alamgir_1604069 Cpp14 0.00s
47 fahim_smm Cpp14 0.00s
48 jayed_al_hasan Cpp14 0.00s
49 Tajir Cpp14 0.00s
50 CSE1604084_Mahir Cpp14 0.00s

Your feedback is our precious!

Or call +88 02 9853138 for support