19 views

Uploaded by Nitesh Sahni

Coding Questions

Coding Questions

© All Rights Reserved

- class modeling
- IMC 2009 Problems With Solutions (Day 1)
- Eular Path
- Sample Ques - ELQ, Comp
- Triang u Laci on Delaunay
- 50120130406025-2
- Week3 Feedback
- Split Block Domination in Graphs
- Mobile Web and Intelligent Information Systems
- Graph Operations on Zero-Divisor Graph of Posets
- Par Met is Manual
- basics (2)
- graph connectivity
- cp9
- imm4573
- 1224-7958-1-PB
- 20061202 New Data Flow Testing
- TSP SCIENCE DIRECT.pdf
- Rgp Request.16 Apr 18docx
- Mathematics for Classical Information

You are on page 1of 8

cubes.

Chandan's son is extremely notorious just like him. So he dropped the cube inside a tank filled

with Coke. The cube got totally immersed in that tank. His son was somehow able to take out the

cube from the tank. But sooner his son realized that the cube had gone all dirty because of the

coke. Since Chandan did not like dirty stuffs so his son decided to scrap off all the smaller cubes

that got dirty in the process. A cube that had coke on any one of its six faces was considered to

be dirty and scrapped off. After completing this cumbersome part his son decided to calculate

volume of the scrapped off material. Since Chandan's son is weak in maths he is unable to do it

alone.

Help him in calculating the required volume.

Input:

The first line contains T denoting the number of test cases. Then T lines follow each line

contains N that is the side of cube.

Output:

For each case output the required volume.

Constraints:

1 T 100

1 N 109

Note:

There is no hole or space between 2 smaller cubes.

Sample Input

(Plaintext Link)

2

1

3

Sample Output

(Plaintext Link)

1

26

Explanation

For the first test case : There is only 1 small cube in a 1 x 1 x 1 cube. This cube gets coke on all of

its 6 faces so it needs to be scrapped off. Volume of material that gets scrapped is 1 x 1 x 1 = 1.

Once upon a time, the Earth was a flat rectangular landmass. And there was no life. It was then

that the sky lit up with meteorites falling from out of space. Wherever they fell on the planet, a

river was born, which flowed in all 4 directions (North, East, West, South), till the waters reached

the edge of the Earth and simply fell off into space.

Now, these rivers criss-crossed and divided the one huge landmass (Pangaea) into many smaller

landmasses. Now the lifeless (there was no life, remember?), want to know the number of

landmasses on the planet after all the meteorites have fallen. They also want to know the area of

the smallest and largest landmass. Can you help the lifeless in this question?

Input:

First line contains T which is the number of test cases.

First line of every test case contains 3 integers N, M, Q where N and M are coordinates of the

bottom right corner of the planet and Q is the number of meteorites.

The next Q lines contains the coordinates X, Y where each of the meteorites fell.

Output:

For each test case, output a line containing 3 integers indicating the number of regions, the

minimum area and the maximum area.

Constraints:

1 T 10

2 N, M 105

0 Q 105

1XN

1YM

Scoring:

Note:

The Earth can be assumed to be a rectangle with top left point as (1,1) and bottom right

point (N,M).

The rivers may be assumed to be flowing in very thin straight lines parallel to the edges

of the planet.

Sample Input

(Plaintext Link)

1

5 5 2

2 3

4 4

Sample Output

(Plaintext Link)

9 1 4

Explanation

Refer to image below showing all the regions with individual areas.

Problem

Editorial

My Submissions

Shil has an array of N elements A1 , A2, ... ,AN . He also has an integer K. He wants to find out

value of Square Sum for every i from 1 to N-K+1.

The value of Square Sum for certain i is defined as 1 j K (j2 Ai+j-1).

Input:

First line of input consists of two integers N and K. Next line consists of N integers A1 , A2, ... ,AN.

Output:

Output N-K+1 integers where ith integer corresponds to Square Sum of i. Print Square Sum

modulus 109+7.

Constraints:

1 K N 106

1 Ai 109

Sample Input

(Plaintext Link)

6 3

6 9 10 10 4 6

Sample Output

(Plaintext Link)

132 139 86 80

Problem

Editorial

My Submissions

Dilku was thinking about the first time he met his girl... It was indeed a walk to remember. The

romantic weather and her silly talks. He was completely mesmarized. Those were the days!..

Today is his girl's birthday and he wants to make it special for her. He wants to again take her on

a "special walk" that they would remember for the lifetime.

The city in which Dilku lives is represented as an unweighted directed graph with N nodes and M

edges. A "special walk" in the graph starting at node u is a simple path that begins and ends at

the same node u.

Formally, A special walk is path u , a1 , a2 , a3 ,..., ai ,.... , u where ai are distinct and not equal to

u for all i.

Now since Dilku is really nervous about taking his girl out, he needs your help. For every node in

the given graph, tell whether it is possible for Dilku to take his girl on a "special walk" starting at

that node.

Input:

First line of a two space separated integers denoting N and M, the number of nodes and number

of directed edges in the corresponding graph.

Following M lines contain two space separated integers u v denoting a directed edge in the

graph from vertex numbered u to vertex numbered v.

Output:

Print N space separated integers, where ith integer can be either 1 or 0 depicting whether it is

possible to go on a special walk starting at node i or not.

Constraints:

1 N 105

1 M 2 105

1 u, v N

Sample Input

(Plaintext Link)

5 5

1 2

2 3

3 4

4 5

4 2

Sample Output

(Plaintext Link)

0 1 1 1 0

Explanation

In the given graph , there is just one directed cycle : 2-->3-->4-->2. Hence, for all nodes on this

cycle, the answer is yes and for others the answer is no.

Problem

Editorial

My Submissions

Kevin thinks that array A is beautiful if

There doesn't exist any number x and tuple (y1, y2, ..., yK) such that Ax = Ay1 Ay2 ...

AyK (yi < x).

Kevin knows M bad numbers Bi. Kevin also knows that 1 isn't a bad number. Now he wants to

find lexicographically smallest beautiful array.

Input format:

The first line of the input contains three numbers N, K, M. The next line contains M integers - B i.

Output format:

Output N integers - lexicographically smallest beautiful array.

Constraints:

2 N, K 2 104

0 M 2 104

0 Bi 109

Sample Input

(Plaintext Link)

7 2 3

4 7 47

Sample Output

(Plaintext Link)

1 2 3 5 8 11 12

- class modelingUploaded byKrupesh Patel
- IMC 2009 Problems With Solutions (Day 1)Uploaded byLiu Shanlan
- Eular PathUploaded byxenulhassan
- Sample Ques - ELQ, CompUploaded byRaghavender Reddy
- Triang u Laci on DelaunayUploaded byloki_ss
- 50120130406025-2Uploaded byIAEME Publication
- Week3 FeedbackUploaded byAbhishek Das
- Split Block Domination in GraphsUploaded byInternational Journal of Research in Engineering and Technology
- Mobile Web and Intelligent Information SystemsUploaded byauobsalari
- Graph Operations on Zero-Divisor Graph of PosetsUploaded byIoan Degau
- Par Met is ManualUploaded byPrashanth Sheshappa
- basics (2)Uploaded byNaman Dosi
- graph connectivityUploaded byjohnjabaraj
- cp9Uploaded byvsukrishna
- imm4573Uploaded byAnonymous prKGoG7s
- 1224-7958-1-PBUploaded bySrijit Sanyal
- 20061202 New Data Flow TestingUploaded byUmamageswari Kumaresan
- TSP SCIENCE DIRECT.pdfUploaded byNorma Syahnasa Diah Islamy
- Rgp Request.16 Apr 18docxUploaded byAHSAN JILANI
- Mathematics for Classical InformationUploaded bysiti rahaimah
- Using Logarithmic GraphsUploaded byAC
- linalgpaper2Uploaded byKelli Chang
- MIT6_096IAP11_sol04Uploaded byVinay
- Activity NetworkUploaded byrachiyata
- 1.7_Transformations.pdfUploaded byRashid Davis
- ConnectivityUploaded byPratik Gupta
- evo-coloring-cc-hl-og-aa-2002Uploaded byEmilian Mihalache
- design and algorithmUploaded byArchaKhandelwal
- Maple Implementation of the Kirchhoff’s Third and Fourth LawsUploaded byArlene Janse van Rensburg
- An Algorithm for via Minimization in Two Layer Channel Routing of VLSI DesignUploaded byvenkataraogg

- 229_IOTUploaded byNitesh Sahni
- String ReverseUploaded byNitesh Sahni
- unit_4_javaUploaded byAshutosh Saxena
- 14031-9556-c[1].s.Uploaded byNitesh Sahni
- Experiment 1Uploaded byNitesh Sahni
- News Feedbox CodeUploaded byNitesh Sahni
- Date SheetUploaded byNitesh Sahni
- Java Program ListUploaded byNitesh Sahni
- IndexUploaded byNitesh Sahni
- narayanaUploaded bykoolestnitesh
- shortcut keys for windowsUploaded byGaasMaasK
- VirusUploaded byNitesh Sahni
- Some Teriible ContentUploaded byNitesh Sahni

- WA Readme-3.6.31.0 BetaUploaded byAnes Hrnjić
- Design of Single Point Cutting ToolUploaded byChinmay Das
- CBSE Class 12 Physics Blue PrintUploaded byPrathap Kumar
- Digital Signal Processing - A. Anand Kumar- By www.EasyEngineering.net.pdfUploaded bysoujanya
- Pic Microcontroller Basic ProjectUploaded byprajnith
- Haiwell PLC CatalogueUploaded byChristiaNdrés Carvajal
- Hot Mix Asphalt Railway Trackbeds; Trackbed Materials, Performance Evaluations and Significant Implications - RoseUploaded bymkon79
- Evolution of Archery in AmericaUploaded byArchery Duns
- Pricing of MBS StripUploaded byapi-3765980
- 14MHz SSBUploaded byGonzags
- Lect4 Design of Tension MembersUploaded byYashu Handa
- ciip09_1564_1571.2683Uploaded bymuse
- f-whaUploaded byAlsayed Rabiea Miesalam
- Spindle PresentationUploaded byLuis Arturo Espinosa López
- Time in Islamic KalamUploaded byAtaul Mukit
- 024_pp 827-832.pdfUploaded bySaroj Gtm
- Monero and - The Definitive Guide _ MoneroMiningUploaded byDamian Rodriguez
- Rothera Test JurnalUploaded byAzra Zahrah Nadhirah Ikhwani
- International Journal of Minerals, Metallurgy and MaterialsUploaded bystativa030
- Autopipe New User Tips 9aUploaded byLuisRiosQ
- Alternate FuelsUploaded byAjayKumar
- Enhanced Security Using Biometrics and Elliptic Curve CryptographyUploaded byEditor IJRITCC
- ME2405 Lab Manual.docUploaded bysanthoshjoys
- Algorithms - Chapter 4 Divide_conquerUploaded bysiddiquentc
- 12)14549_FULLTEXT.pdfUploaded byAyu Rosyida Zain
- Polarisation of Ions (AS)Uploaded byKevin The Chemistry Tutor
- deck slabUploaded byAhsan Sattar
- Reliance Training 03 HiEUploaded byAjaykumar Singh
- Timing Diagram (Part 3 - Cycloid Cam Profile Analysis)Uploaded byVitorHugo
- EfficiencyUploaded byDanielGuimarãesCosta