0% found this document useful (0 votes)
8 views14 pages

booklet 11_38

Uploaded by

c201012
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)
8 views14 pages

booklet 11_38

Uploaded by

c201012
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/ 14

Intra IIUC Junior Programming

Contest Spring 2024 - Main

https://toph.co/contests/training/h8fkzn8
Schedule
The contest will run for 3h0m0s.

Rules
This contest is formatted as per the official rules of ICPC Regional Programming
Contests.

You can use C++17 GCC 13.2, C++20 Clang 16.0, C++20 GCC 13.2, C++23 GCC 13.2, C11
GCC 13.2, C17 GCC 13.2, C23 GCC 13.2, D8 11.8, Free Pascal 3.0, Java 1.8, Node.js
10.16, PHP 8.3, PyPy 7.1 (3.6), Python 3.12, Ruby 3.2, and Whitespace in this contest.

Be fair, be honest. Plagiarism will result in disqualification. Judges’ decisions will be


final.

Notes
There are 7 challenges in this contest.

Please make sure this booklet contains all of the pages.

If you find any discrepencies between the printed copy and the problem statements in
Toph Arena, please rely on the later.

Disclaimer
The contents of this contest have not been reviewed by Toph and do not necessarily
represent Toph's views.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 2 of 14


A. The Last Minute
What's the most precious thing on earth? While opinions may differ, time is
undoubtedly among them.

So let's start with a simple problem about time.

You're given a time specified by hour and minute in the 24-hour format. What was the
last minute?

In the 24-hour format, time runs from 00:00 (midnight) to 23:59 (one minute before
midnight). Hours are represented from 00 to 23 and minutes from 00 to 59. After
23:59, the clock resets to 00:00, marking the start of a new day, and the cycle repeats
continuously.

Input
Only line contains two integers, h and m (0 ≤\leq
≤ h ≤\leq
≤ 23, 0 <= m <= 59).

Output
Output the previous minute.

Both the hour and minute must be of two digits.

Samples
Input Output
03 24 03 23

Input Output
14 00 13 59

Input Output
00 00 23 59

Intra IIUC Junior Programming Contest Spring 2024... | Toph 3 of 14


B. The Queue
IIUCCPS has arranged a Webinar on “Competitive Programming” at IIUC Central
Auditorium. Students need to collect a coupon for Lunch. Coupons will be given after
all students stand in a single queue. Initially, students will randomly stand in the
queue, but later they will re-arrange themselves according to their semester
sequence. Students are going to stand in the queue semester wise, i.e., 1st-semester
students will be in front, followed by 2nd-semester students and so on. Unfortunately,
a student from semester X arrived a few moments after arranging the queue. The
seniors of CSE kindly agreed to let him stand with his semester but students of
semester X insisted on standing at the back of their semester queue. If his semester
doesn’t appear in the queue, he will just start his own semester in the queue.

Your task is to find the position of the late student of semester X in the final queue.

Input
The first line contains an integer T (1 ≤ T ≤ 10) - the number of test cases.

105 ) — length of the queue


First line of each test case contains two integers N (1 ≤ N ≤ 10510^5
and X (1 ≤ X ≤ 8) — semester of late student.

Second line contains the initial queue denoting the semester of the students. The
semesters will be represented without any spaces in between them.

It is guaranteed that all the students will be from the 1st to the 8th semester.

Output
Print an integer: the position of the student from semester X.

Samples
Input Output
2 4
7 2 5
2213887
5 5
34622

Intra IIUC Junior Programming Contest Spring 2024... | Toph 4 of 14


C. 3-Distinct
You are given two integers, XX
X and YY
Y.
You have to multiply 33
3 distinctdistinct
distinct integers to XX
X such that XX
X becomes YY
Y.

Input
The first line contains a single integer TT
T ( 11
1 ≤\leq
≤ TT
T ≤\leq
≤ 10) — the number of test cases.
10)
The only line of each test case contains two integers, XX
X and YY
Y (11
1 ≤\leq
≤ XX
X <<
< YY 107 ).
Y ≤\leq
≤ 10710^7

Output
For each test case, output “YesYes
Y es” if you can multiply33
3distinctdistinct
distinct integers withXX
X such
that X∗A∗B∗C=YX*A*B*C=Y
X ∗ A ∗ B ∗ C = Y where
(2<=A<B<C<=1e7)
(2 <= A < B < C <= 1e7).
(2
If
<= there are no such 33
3 distinctdistinct
distinct integers, output “NoNo
N o”.
A
Samples
<
B
<Input Output
C3 Yes
<=1 210 No
2 4 No
1e7)
2 11

In the 1st1st
1st case: we can transform XX
X into YY
Y by multiplying XX
X by 5, 6, 7.
6,
In 2nd2nd
2nd and3rd3rd 33distinctdistinct
3rd cases: we don't have any 3 distinct integers75,6,7X∗A∗B∗C=YX*A*B*C=Y
such that X ∗A∗B∗
C =Y.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 5 of 14


D. Weird Algorithm
You will be givenQQ
Q queries with two integers, L and R. Let's assume that you have a
109 .
special array A which has indices up to 10910^9

All the elements of the array are initially zero.

With each query, do the following operation:

1)Add1)
1)Add 1 to every AiA_i (L≤i<R)
Ai where (L ≤ i < R) and
Add (L
2)Add2)
2)Add (-1) to ARA_R
AR \leq
Add i operations:
More formally do the following
<
ALA_L
AL = ALA_L
AL + 1 R)
AL+1A_{L+1}
AL+1 = AL+1A_{L+1}
AL+1 + 1
AL+2A_{L+2}
AL+2 = AL+2A_{L+2}
AL+2 + 1
………………………………….

………………………………….

AR−1A_{R-1}
AR−1 = AR−1A_{R-1}
AR−1 + 1
ARA_R
AR = ARA_R
AR - 1
After processing all queries, print the maximummaximum
maximum element of the special array A.
NOTE:NOTE:
NOTE : All L and R are distinct. In other words, there are no repeated values for
any of the queries.

Input
The first line contains a single integer QQ ≤ Q ≤ 2 ∗ 105 )— the number of query.
(1≤Q≤2∗105)
Q (1
(1
Next QQ
Q lines contain two integer LL
L and RR
R ≤ L < R ≤ 109 ).
(1≤L<R≤109)
(1
\leq
Q(1
\leq
Output \leq
L
2*10^5)
After processing all queries, print the maximummaximum
<
maximum value of the array A.
R

Intra IIUC Junior Programming Contest Spring 2024... | Toph 6 of 14


Samples \leq
10^9)
Input Output
3 2
1 3
2 5
4 6

Explanation:

Intra IIUC Junior Programming Contest Spring 2024... | Toph 7 of 14


E. Game Changer
Riktika has recently discovered a game called the Largest Special Component from
her dream. Excited about it, she decides to play with her friend, Ankita.

In this game, each player is given an undirected graph with N vertices and M
undirected edges and The graph is not necessarily connected. Each player has the
choice to remove one or more edges from the given graph to make it Largest
Special Component.

The winner of the game is the one who constructs the largest special component.

Note:

A component of an undirected graph is a subgraph in which each pair of nodes is


connected with each other via a path in some way.

A Special Component is defined as a component without cycles.

A Largest Component refers to a component containing the maximum number of


nodes.

Input
2 ∗ 105 , 1 ≤ m ≤2∗1052*10^5
The first line contains two integer numbers n and m ( 2 ≤ n ≤2∗1052*10^5 2 ∗ 105 )
— the number of vertices and edges, respectively.

ii
The second following m lines contain edges for Riktika: edge i is given as a pair of
vertices viv_i
vi and uiu_i
ui (1≤viv_i
vi ,uiu_i
ui ≤ n, viv_i
vi ≠uiu_i
ui ).
ii
The third following m lines contain edges for Ankita: edge i is given as a pair of
vertices viv_i
vi and uiu_i
ui (1≤viv_i
vi ,uiu_i
ui ≤ n, viv_i
vi ≠uiu_i
ui ).

Output
Print one integer — the maximum number of nodes and one character — the first
letter of the winner ( ‘R’ or ‘A’ ) and in case of a draw (‘D’).

Samples
Input Output
6 6 4 A

Intra IIUC Junior Programming Contest Spring 2024... | Toph 8 of 14


Input Output
1 2
2 3
1 3
4 5
5 6
6 4
1 2
2 3
3 4
4 1
1 3
2 4

Explanation:
The picture below shows the graph of Riktika.

Riktika's initial graph consists of two cyclic components (displayed on the left). To
construct special components, we can remove a single edge from each component. For
example, removing edges (1 - 2) and (5 - 6) creates two special components (displayed
on the right). One special component includes nodes (1, 2, 3) while the other comprises
nodes (4, 5, 6).

Both components have 3 nodes each. Thus, the largest special component in Riktika's
graph contains 3 nodes.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 9 of 14


Input Output
The picture below shows the graph of Ankita.

In Ankita's initial graph, there is one cyclic component and two single nodes without
edges (displayed on the left). One of the ways to make the cyclic component special, we
can remove edges (1 - 2), (1 - 3) and (3 - 4). This results in a graph with three special
components consisting of nodes (5), (6) and (1, 2, 3, 4) (displayed on the right).

Among these components, the largest one consists of nodes (1, 2, 3, 4); totaling four
nodes.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 10 of 14


F. Garden
There’s a garden with n trees, where the i-th tree has an initial height hih_i
hi . The owner of
the garden wants all the trees to be of equal height.

The growth of these trees is not natural; instead, it depends on the application of
nutrients. Each tree takes b days to grow by 1 millimeter with the aid of nutrients.
Additionally, once nutrients are applied to a tree at day-x, no more nutrients can be
added to that tree before day-(x+b).

Also, trees can be trimmed from the top. It takes c days for a tree to be trimmed by 1
millimeter.

Nutrients can be applied to a tree multiple times and also a tree can be trimmed
multiple times.

In a single day, any number of trees can receive nutrients and any number of trees can
be trimmed.

Your task is to determine the minimum number of days required to make all the trees
equal in height. You can choose any desired height for the trees of your choice.

Input
The first line contains an integer t (1 ≤\leq 105 ) — the number of test cases.
≤ t ≤\leq
≤ 10510^5
Each test case contains two lines.

The first line of each test case contains three integer n, a, b (1≤\leq 105 , ≤\leq
≤ n≤\leq
≤10510^51 ≤ a, ≤\leq
b≤
109 ) - the number of trees, days required by trees to grow 1 millimeter and days
10910^9
required to trim a tree by 1 millimeter.

The second of each test case contains n integers hih_i


hi (1 ≤\leq
≤ hih_i109 ).
hi ≤\leq
≤ 10910^9
2 ∗ 105 .
The sum of n over all test cases will not exceed 2∗1052*10^5

Output
For each test case, output the minimum number of days required for all the trees to be
of equal height.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 11 of 14


Samples
Input Output
2 0
1 2 3 3
1
2 2 3
1 3

For the first case, nothing to be done for a single tree.

For the second case,


Day 0: We give nutrients to the first tree and start trimming the second tree.
Day 1: Both actions continue.
Day 2: The first tree grows to 2 millimeters after 2 days of receiving nutrients.
Day 3: The second tree is trimmed for 3 days and reaches a height of 2 millimeters.

After 3 days, both trees are of equal height of 2 millimeters. It can be shown that they
cannot be made of equal height in less than 3 days.

Intra IIUC Junior Programming Contest Spring 2024... | Toph 12 of 14


G. Efficient Tour
Gopher is embarking on yet another adventurous tour, this time acrossNN
N cities, each
uniquelyuniquely distinctdistinct
uniquely defined by its two-dimensional coordinates and having distinct Power.
Gopher will visit all the cities but can only visit each city once. He will start from the
city with the lowest Power and return to the starting city after visiting all the cities.

But, as with any journey, there are rules to abide by:

1. Before reaching the city with the highest Power, Gopher can go from city ii
i to city
jj
j only if the Power of city iii is lower than that of city jj (Poweri<Powerj)
j (P oweri < P owerj ).
(Power_i
2. Once he reaches the city with the highest Power, Gopher's path can go from city
<
ii
i to cityjjj if the Power of ii city i is higher than that jjof(Poweri>Powerj)
Power_j)city j (P oweri >
P owerj ). (Power_i
>
The cost of moving fromii city ijjto city j is calculatedPower_j) using the formula
(xi − xj )2 + (yi − yj )2 , where (xi,yi)
(xi−xj)2+ (xi , yi ) represents the coordinates of city ii i and
(yi−yj)2\sqrt{(x_i
(x j , yj ) represents the coordinates (x_i,
(xj,yj) of city jj
j.
-
(x_j, y_i)
Gopher
x_j)^2
y_j) could complete his tour through various routes, he wants to accomplish it with
the
+ minimum cost. Thus, he turns to you for assistance in this.
(y_i
-Input
y_j)^2}
N (2 ≤ N ≤ 3 × 103 ) denoting the number of
The first line will contain one integerN(2≤N≤3×103)N(2\leq
cities Gopher will visit in his tour. N
\leq
Next NN N lines will contain three integers Poweri(1≤Poweri≤N)Power_i(1
P oweri (1 ≤ P oweri ≤ Nxi,yi(1≤xi,yi≤106)x_i,y_i
3\times{10} ), xi , yi (1 ≤
6
xi , yi ≤ 10 ), PoweriPower_i
P oweri denoting the ^3)\leq
Power ithi_{th} and xi , yi\leq
of ith cityxi,yix_i,y_i denoting the
coordinator of ithi_{th}
ith city. Power_i\leq x_i,y_i
N) \leq
{10}
Output ^6)
Print a single line containing the minimum cost to visit all the cities in the Gophers
10−4 will be ignored.
tour. Errors less than 10−410^{-4}

Samples
Input Output
14.9225

Intra IIUC Junior Programming Contest Spring 2024... | Toph 13 of 14


Input Output
4
1 2 3
2 6 3
3 3 7
4 5 2

The minimum cost path is (2,3)->(6,3)->(5,2)->(3,7)->(2,3).

Intra IIUC Junior Programming Contest Spring 2024... | Toph 14 of 14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy