DCP-324: Special Matrix Back to All Problems

Medium Beginners Problems > Ad-hoc


Tuli loves to play with matrix. She makes a special matrix of size **N*N**, the values of the matrix are from **1 to N*N**. The matrix for N = 4 exactly looks like as the picture given below, ![enter image description here][1] Now, Tuli will ask you several queries, she will gives you an integer **M (1 ≤ M ≤ N*N)** in each query, you have to tell her the position of the number **M** in her special matrix. Can you do it faster? Input: ------ Input starts with two integer **N (1 ≤ N ≤ 1000)** and **Q (1 ≤ Q ≤ min(N*N, 10^5))**, denoting the total number of columns as well as the total number of rows in the matrix and the total number of queries respectively. Each query contains an integer **M (1 ≤ M ≤ N*N)**. Output: ------- For each query, output the position of **M** in the matrix in **(x, y)** form, where *x* is the index of the raw & *y* is the index of column. Here indexes are 1 based. Output formatting will be like this : **x,[ SPACE ]y** Sample Input ------------ 4 3 5 11 14 Sample Output ------------- 2, 1 3, 4 1, 3 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/e6ea1227-d91a-c6a2-a73f-08d48cb76872_e7446ce46b524100863efa7421bb9dae_W300xH236.png


Problem Setter:

Emrul Chowdhury

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

62/172

Solve/Submission

Ranking

# User Language Timing
01 feodorv Cpp14 0.02s
02 Morass Cpp14 0.02s
03 anik_JU Cpp14 0.03s
04 mir003 Cpp14 0.03s
05 njrafi Cpp14 0.03s
06 badhansen123 Cpp14 0.03s
07 emrul Cpp14 0.03s
08 Foysol_Ahmed Cpp14 0.03s
09 Pure_Protea Cpp14 0.03s
10 MRITuhin Cpp14 0.03s
11 shahed_shd Cpp14 0.03s
12 faceless_void Cpp14 0.03s
13 Mahbub_Rahman Cpp14 0.04s
14 sazal_dev Cpp14 0.04s
15 arabin Cpp 0.04s
16 Optimus_primeV2 Cpp14 0.04s
17 kissu_pari_na Cpp14 0.04s
18 SbrTa Cpp14 0.04s
19 daihan_mbstu Cpp14 0.05s
20 bug_is_everywhere Cpp14 0.06s
21 ssavi Cpp14 0.06s
22 priojeet_priyom Cpp14 0.08s
23 nurshuvo51 Cpp14 0.08s
24 Islam_Rafat Cpp14 0.10s
25 tariqiitju Cpp14 0.12s
26 shamimjucse Cpp14 0.13s
27 saiful130104 Cpp14 0.15s
28 AlaminJust Cpp14 0.15s
29 ____ Cpp14 0.15s
30 _c_k_r_ Cpp14 0.15s
31 ifat_just Cpp14 0.16s
32 Rajan_sust Cpp14 0.17s
33 ovis96 Cpp14 0.18s
34 _GhOstMan_ Cpp14 0.18s
35 fearless_hasan Cpp14 0.21s
36 shailyroy Cpp14 0.21s
37 Jisancse Cpp14 0.22s
38 rayhan50001 Cpp14 0.22s
39 Gang_Of_Three_01 Cpp14 0.38s
40 SakibAlamin Cpp14 0.43s
41 noorashuvo CSharp 0.44s
42 Zayed Cpp14 0.54s
43 Masum_ice Cpp14 0.67s
44 bishal_biswas Cpp14 0.95s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support