69 visualizações

Enviado por Abhiroop

Problems

- cps125-fin-w09
- Python Intelhex
- CassandraQueryLanguage Quick Reference Card
- Excel Tips
- CString Management
- SS ZG526-L3
- API Blindspots- Why Experienced Developers Write Vulnerable Code
- Sending Email With PDF Attachment
- 10.String Handling
- Notes
- eob engine explanation
- SAS Functions
- Writing Dll Files
- comp322_05
- Valuable Advice
- mqtt-v3.1.1.doc
- Perl Regular Expression
- 05_Kaavian_Control_Statements.ppt
- 124269949-ODB-Format-Description-v7.pdf
- finall.txt

Você está na página 1de 14

cell. Both players have one piece; it is in the middle position of the row closest to his/her side of the

board. Players can place their piece on squares only.

1. Moving one's piece to a neighboring (horizontally, vertically, or diagonally) position that contains a

square but not the opponent's piece.

2. Removing any square with no piece on it.

The player who cannot move his/her piece loses the game.

Now you are going to write code to play Isola with others or computer bot.

Input

The input will be an 7x7 matrix consisting only of 0, 1, 2 and -1. Then another line will follow which will

contain a number 1 or 2, which is your player id. The difference between player 1 and 2 is that player 1

plays first in start of the game.

In the given matrix, top-left is [0,0] and bottom-right is [6,6]. The coordinate of a cell is represented by

[row, column]. Rows increases from top to bottom and column increases from left to right.

The cell marked 0 means it contains a square which is yellow in color. The cell marked 1 means it

contains player 1's piece which is blue in color. The cell marked 2 means it contains player 2's piece

which is red in color. The cell marked -1 means it doesn't contain the square. The board is brown in color.

Output

Print the coordinates of the neighbor cell [row, column] where you want to move your piece. In next line,

print the coordinates of any cell to remove the square.

Starting state

0002000

0000000

0000000

0000000

0000000

0000000

0001000

Scoring

The scores will be calculated by running a tournament of all submissions at the end of the contest. Your

last submission will be used while running the tournament. Score will be assigned according to Elo rating

system.

Example of a bot which plays the game randomly, while avoiding invalid

move: https://code.hackerearth.com/6f1718R

Sample Input

(Plaintext Link)

0 0 0 2 0 0 0

0 0 0 -1 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 1 0 0

0 0 0 0 0 0 0

2

Sample Output

(Plaintext Link)

0 2

4 4

Explanation

This is player 2's turn, and the player moves his/her piece to cell [0, 2] and removes the square at cell [4,

4].

After his/her move the state of game becomes:

0

0

0

0

0

0

0

0

0

0

0

0

0

0

2 0 0 0 0

0 -1 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 -1 0 0

0 0 1 0 0

0 0 0 0 0

Your friend Max has written a string S in your textbook. The string consists of lowercase latin letters. The

problem is that Max is not good at writing at all! Especially, you never know if he wanted to write "w" or

two consecutive "v". Given the string S, return the minimum and maximum length of a word which can

be represented by it. The input string represents what you initially think the word is.

Input format:

In the first line there is a single integer N denoting the length of word S. In the second line there is

string S itself.

Output format:

Print the minimum and the maximum length of a word which can be represented by S. Output these

numbers in one line and separate them by a single space.

Constraints:

N <= 106

Sample Input

(Plaintext Link)

5

avwvb

Sample Output

(Plaintext Link)

4 6

Explanation

The shortest word which can be represented by this string is awwb, while the longest is avvvvb

At HackerEarth we love play checkers and we play it a lot! However, we play a very specific kind of

checkers. Our game is played on 32x32 board. If you are a programmer, you probably know why the

board size is 32. Maybe we will describe details of the game in a future challenge, but for now, the only

thing you have to know is that we represent the board as a 2 dimensional table where '_' denotes a white

field while '#' denotes a black field. A valid board looks like this:

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#

#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_

You are given a big 2 dimensional table S and your task is to find out how many occurrences of a valid

board are in S.

Input format:

In the first line there are two integers N, M denoting the number of rows and the number of columns of the

input tableS. N lines follow. Each of them consisting of M characters. The j-th character in the i-th of these

lines denotes the j-th character in the i-th row of S. All characters are either "_" or "#".

Output:

In a single line output the number of occurrences of a valid board in S.

Constraints:

1 <= N <= 2000

1 <= M <= 2000

Sample Input

(Plaintext Link)

42 42

__________________________________________

__________________________________________

__________________________________________

__________________________________________

__________________________________________

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____

_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#______

__________________________________________

__________________________________________

__________________________________________

__________________________________________

__________________________________________

Sample Output

(Plaintext Link)

1

Explanation

As you can see, there is just one valid board located in the middle of the string.

As a programmer, you sometimes have to deal with some math and this is the time to do it. You are given

a list of binary relations, equalities and inequalities, like a = b, a != d, b = c etc. Your task is to

output YES if you can assign integers to input variables in such a way, that you can satisfy all equalities

and inequalities. Otherwise you should outputNO.

Input format:

In the first line there is one integer T denoting the number of test cases. Description of T test cases follow.

Each one have two integers N and K given in the first line denoting the number of variables and the

number of relations between them for this test case. All variables are represented by integers in range [1,

N]. K lines follow. Each of them is of the form "x1 R x2" where x1 and x2 are integers representing

variables and R is either "=" or "!=" and denotes the kind of relation between these variables.

Output format:

Output exactly T lines. In i-th of them, output the answer to the i-th test case.

Constraints:

T <= 10

1 <= N, K <= 106

Sum of N in one test file does not exceed 106

Sum of K in one test file does not exceed 106

Sample Input

(Plaintext Link)

2

2 2

1 = 2

1 != 2

3 2

1 = 2

2 != 3

Sample Output

(Plaintext Link)

NO

YES

Explanation

There are 2 test cases. In the first one, you cannot fulfill all relations, because equality and inequality of

two number cannot be both true. In the second one, you can for example assign 10 to 1 and 2 and 20 to 3

in order to fulfill all relations.

It's your birthday today, right? If it is, then we wish you Happy Birthday and good luck in the contest. But,

even if it is not, you have to be ready to give candies to your friend when this day comes!

You have N candies to distribute and you decide to give them to anyone who shows up. Because this is

your day, you invented your own method of distributing all these candies . The process is the following:

Initially, there are N candies placed in one pile. While there are any candies left, a person shows up and

do the following:

1. Picks up the first pile with candies, let's call this pile P.

2. If P has one or two candies, he takes all the candies from P. Otherwise, he takes just one candy,

divide the rest into some number of piles, at least 2, of equal sizes and put them in front the other

piles.

Because at HackerEarth we like math, we are interested how many different such processes are there.

We consider two processes different if and only if one distributes candies to different number of people

than the other or both distribute candies to the same number of people and there exists a person who

decides to distribute candies differently in them. You have to return the number of different such

processes modulo M = 109 + 7.

Input format:

In the first and only line there is one integer N.

Output format:

In one line output a single integer - the answer to the problem modulo M = 109 + 7.

Constraints:

1 <= N <= 1012

Sample Input

(Plaintext Link)

5

Sample Output

(Plaintext Link)

2

Explanation

There are 5 candies initially. The first person after taking one candy for himself can divide the other 4

candies in two ways:

1. into 4 piles with 1 candy on each of them

In the first case, 4 people will show up and each of them will take one candy for himself. In the second

case, 2 people will show up and each of the will take 2 candies for himself.

You have recently started playing a brand new computer game called "Mr. President". The game is about

ruling a country, building infrastructures and developing it.

Your country consists of N cities and M bidirectional roads connecting them. Each road has assigned a

cost of its maintenance. The greatest achievement in the game is called "Great administrator" and it is

given to a player who manage to have all cities in the country connected by roads in such a way that it is

possible to travel between any two cities and that the sum of maintenance costs of these roads is not

greater than K.

This is very hard to accomplish, but you are very close to do it. More precisely, you have just discovered a

new method of transforming standard roads into super roads, with cost of maintenance just 1, due to their

extreme durability.

The bad news is that it is very expensive to transform a standard road into a super road, but you are so

excited that you are going to do it anyway.

In addition, because you have a lot of other expenses, you also want to first demolish as many roads as

possible in order to safe some money on their maintenance first and then start working on getting the

achievement. You can demolish any road in the country and that operation does not cost you anything.

Because you want to spend the absolutely minimum money in order to get the achievement, you are

interested in the smallest number of transformations of standard roads into super roads in such a way that

you can do that.

Input format:

In the first line there are 3 integers N, M and K denoting the number of cities in the country, the number of

roads in it and the desired sum of costs of maintenance. M lines describing these roads follow. In each of

them there are 3 integersA, B and C, where A and B denote the endpoints of the road while C denotes

the cost of its maintenance.

Output:

In a single line, output the minimum number of roads which need to be transformed in order to get the

achievement. If you cannot do it no matter what, output -1.

Constraints:

2 <= N, M <= 106

0 <= K <= 1018

1 <= A, B <= N and A != B

1 <= C <= 106

Sample Input

(Plaintext Link)

3

1

2

3

3

2

3

1

25

10

20

30

Sample Output

(Plaintext Link)

1

Explanation

You can transform to super a road either the road between cities 1 and 2 or the road between cities 2 and

3 in order to produce the desired road network of costs respectively 21 and 11. Doing that will cost you

one transformation and it is optimal in this case.

As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings.

Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings

on each other in order to get points. Their strings collide in air and one occurrence of some character in

one string cancels out(character gets deleted) one occurrence of same character in another string. Then,

points are allocated to them based on their remaining characters of strings. There are some points

associated to each character of strings. Total points of any string is calculated by doing sum of points

associated to each character. The total points of string M are given to Marut and total points of

string D are given to Devil at the end of each round. Total score of an individual is summation of scores of

all individual rounds. In the end, whosoever has greater number of points, will win the Hunger Games.

Your task is to find the winner and print his name. Initially, both of them have zero points.

Input:

First line of the input contains 26 space separated integers denoting points associated to each lowercase

English alphabets. First integer denotes points associated to 'a' , second integer to 'b' and so on.

Second line contains an integer Q, denoting number of times game is played.

Then, follow 2*Q lines.

For each game, first line contains string M.

second line contains string D.

Output:

Print "Marut" if Marut wins or "Devil" if Devil wins.

If no one wins i.e they both end up with same scores, print "Draw" (without quotes).

Constraints:

1 Points associated to each character 100

String M and D contains only lowercase english alphabets.

1 |M| , |D| 104

1 Q 1000

|M| = |D|

Note:

Large Input Files. Use Fast input/output.

Sample Input

(Plaintext Link)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

2

abcd

aabb

abc

xyz

Sample Output

(Plaintext Link)

Devil

Explanation

In the first round, one occurrence of 'a' and 'b' is cancelled out in both strings M and D, so final string of

Marut would be cd and final string of Devil would be ab. Total points of string Mare 3+4 = 7 and

string D are 1+2=3. For this round , Marut gets 7 points and Devil gets 3 points.

In the second round, no character of both the strings are common. Total points of string M are 1+2+3=6

and string D are 24+25+26=75. For this round Marut gets 6 points and Devil gets 75 points.

Total final scores are: Marut has 13 points and Devil has 78 points. Hence Devil won the game.

Taru and Chandu both are getting bored. So Taru thinks to play a game and he gives a number to Chandu

and asks him to find the number of combinations formed by divisors in form of prime.

For example:For N = 36 divisor in form of prime are ( 2 , 2 , 3 , 3 )

Number of combinations formed by prime divisor of 36 are 8.

Check the sample I/O for better understanding.

INPUTNumber of test cases T. Next T lines contain a number N.

OUTPUTNumber of different combinations formed by divisors in form of prime of N.

CONSTRAINTS1 <= T <= 100

1 <=N <= 10^12

Sample Input

(Plaintext Link)

1

36

Sample Output

(Plaintext Link)

8

Explanation

2,2,3,3 are divisors in form of prime for 36 and different/unique combinations formed are (2) , (3) , (2,3) , (2,2) , (2,2,3) , (3,3) , (2,2,3,3) , (2,3,3).

- cps125-fin-w09Enviado porHarpreet Singh Sahota
- Python IntelhexEnviado porcarlosalberto_28
- CassandraQueryLanguage Quick Reference CardEnviado porRandy Marmer
- Excel TipsEnviado porviveksinghchd
- CString ManagementEnviado porRodrigo A Saucedo
- SS ZG526-L3Enviado porVishu Kukkar
- API Blindspots- Why Experienced Developers Write Vulnerable CodeEnviado porJexia
- Sending Email With PDF AttachmentEnviado porSudhakar Lankapothu
- 10.String HandlingEnviado porqwernasd
- NotesEnviado porAngelAldrina
- eob engine explanationEnviado porstreamer75
- SAS FunctionsEnviado porkapilkg10
- Writing Dll FilesEnviado porsun3813
- comp322_05Enviado porPranshu Jaiswal
- Valuable AdviceEnviado porapi-3717552
- mqtt-v3.1.1.docEnviado porTaLiban
- Perl Regular ExpressionEnviado porsuneeldv
- 05_Kaavian_Control_Statements.pptEnviado porbarath
- 124269949-ODB-Format-Description-v7.pdfEnviado porcacapouet
- finall.txtEnviado porThavarajah Mathuran
- UploadToS3Enviado pornirmaluk
- Time StrptimeEnviado porvivek
- Search Strings Using String Methods (C# Programming Guide)Enviado porKyle Daly
- 2004 CE CS Paper IBC C VersionEnviado porapi-3739994
- project oop reportEnviado porapi-307821649
- bpj lesson 16Enviado porapi-307093335
- bpj lesson 16Enviado porapi-307095237
- lesson 16Enviado porapi-307094923
- bpj lesson 16Enviado porapi-307093352
- bin2dec_bkup1Enviado porLeon Bands

- Christ as the Ideal Model for YouthEnviado porHonecaMulawan
- CV (Sr. QA QC Engineer)Enviado pormansih457
- armstrong pumpEnviado porrogel_gana
- Bandmaster Loudspeaker NoneEnviado porEric M Rubenstein
- Fusarium and Verticillium WiltsEnviado porcresdumayac
- 03_ThyssenKrupp_ElectricalSteelEnviado porJP
- Legrand USB SeriesEnviado porChoy Ren Yu
- Analysis VowelEnviado porMayora Ulfa
- Oct 2017 English Task i Kif AEnviado porYogi Yogi
- Coatings Word March 2011Enviado porsami_sakr
- cubliCDC13Enviado porDenis Dantas
- re95086_2009-07Enviado porErick Parra
- Writing a Research Article Advice for BeginnersEnviado porghost_724
- DR Cereno v CAEnviado porMarkDungo
- Roman Celeia of NoricumEnviado porSlovenian Webclassroom Topic Resources
- KPMG_Target Operating ModelEnviado porSudip Dasgupta
- BMW Din Golfing Plant MilanEnviado porMilanRao
- MEA RRLEnviado porMeke Cabug-os
- Implementation Guide for Technical Enhancement_April 2011Enviado porboy123
- SIALOGRAPHYEnviado porMithun Jith
- Ensemble Application of Convolutional and Recurrent Neural Networks for Multi-label Text CategorizationEnviado porjeffconnors
- 4.Reproduction of FungiEnviado porWahyuni Irmal
- 14 Fracture MechanicsEnviado porAlexander Narváez
- Natural Gas System Training UlEnviado porBadrul Hisham
- Selected Works of Georges PalanteEnviado porRicky Moore
- Kera Ritual Menu_with DensifiqueEnviado pore.K.e.k
- Azure vs AWSEnviado porDivyaanshu Singh
- Claudius Victor Spencer Diary 1845Enviado porLeena Rogers
- EmpireofNeoMemorybyHeribertoYepez.pdfEnviado pordiazbarbaradiaz
- Configure Symbols for components.pdfEnviado porEduardo Martinez