0% found this document useful (0 votes)
30 views2 pages

Problem - D - Codeforces

Vadim is tasked with filling a 2^n × 2^n table with integers in a specific order and has a series of questions regarding the table's contents. The questions involve determining the number in a specific cell or finding the coordinates of a given number. The document outlines the input format for multiple test cases and provides examples of the expected output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Problem - D - Codeforces

Vadim is tasked with filling a 2^n × 2^n table with integers in a specific order and has a series of questions regarding the table's contents. The questions involve determining the number in a specific cell or finding the coordinates of a given number. The document outlines the input format for multiple test cases and provides examples of the expected output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

23:06 8/4/25 Problem - D - Codeforces

|
QuanVanHoang | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN

PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS STANDINGS CUSTOM INVOCATION

Codeforces Round 1016 (Div. 3)


D. Skibidi Table Contest is running
time limit per test: 2 seconds
00:43:19
memory limit per test: 256 megabytes
Contestant
Vadim loves filling square tables with integers. But today he came up with a way to do it for fun!
Let's take, for example, a table of size 2 × 2, with rows numbered from top to bottom and
columns numbered from left to right. We place 1 in the top left cell, 2 in the bottom right, 3 in the
bottom left, and 4 in the top right. That's all he needs for fun!
→ Submit?
Fortunately for Vadim, he has a table of size 2n × 2
n
. He plans to fill it with integers from 1 to
2n
2 in ascending order. To fill such a large table, Vadim will divide it into 4 equal square tables, Language: GNU G++20 13.2 (64 bit, wi
filling the top left one first, then the bottom right one, followed by the bottom left one, and finally
Choose
the top right one. Each smaller table will be divided into even smaller ones as he fills them until he Chọn tệp Không có …được chọn
file:
reaches tables of size 2 × 2, which he will fill in the order described above.
Submit
Now Vadim is eager to start filling the table, but he has q questions of two types:

what number will be in the cell at the x -th row and y-th column;
in which cell coordinates will the number d be located.

Help answer Vadim's questions.


Input
Each test consists of several sets of input data. The first line contains a single integer t
(1 ≤ t ≤ 10) — the number of sets of input data. The following lines describe the input data

sets.

In the first line of each data set, there is an integer n, describing the size of the table
(1 ≤ n ≤ 30) .

In the second line of each data set, there is an integer q — the number of questions
(1 ≤ q ≤ 20 000).

In the following q lines of each data set, the questions are described in the following formats:

-> x y — What number will be in the cell (1 ≤ x, y ≤ 2 ) ; n

<- d — In which cell coordinates will the number (1 ≤ d ≤ 2 2n


) be located.

It is guaranteed that the sum of q over all test cases does not exceed 20 000.

Output
Output the answers to each question on a separate line.

Example
input Copy

2
2
5
-> 4 3
<- 15
<- 4
-> 3 1
-> 1 3
1
8
-> 1 1
-> 1 2
-> 2 1
-> 2 2

https://codeforces.com/contest/2093/problem/D 1/2
23:06 8/4/25 Problem - D - Codeforces
<- 1
<- 2
<- 3
<- 4

output Copy

7
2 3
1 2
9
13
1
4
3
2
1 1
2 2
2 1
1 2
Note
This is how the filled table from the first example looks:

Codeforces (c) Copyright 2010-2025 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Apr/08/2025 23:02:30UTC+7 (g1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions

Supported by

https://codeforces.com/contest/2093/problem/D 2/2

You might also like