CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Challenge 2013
    • May Cook-Off 2013
    • May Challenge 2013
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • Campus Chapters
    • Host your Contest
    • Go for Gold
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
    • Top Contributors on Discuss
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(medium) » Domain Dilemma

Domain Dilemma

Problem code: DDILEMMA

  • Submit
  • All Submissions

All submissions for this problem are available.

One of our businesses involves selling domain names. To that effect, we have an online interface where potential buyers of domain names can check the availability of domain names, and find out how much it is going to cost them.

Domain tasting is a frowned upon practice in our industry wherein people register domain names that are typos of existing domain names in order to make money through displaying ads to the traffic received on these typos. For instance if one were to register "directo.com" one could potentially get traffic from people who were trying to reach "directi.com" but instead mis-typed the last character.

In order to disincentivize tasters from registering typos of existing domain names, we wish to levy a surcharge on a domain name which is a typo of an existing domain name. The amount of surcharge would depend on the type and number of transformations required to convert an existing domain to a domain name that someone wishes to register.

The following type of transformations exist alongwith their cost -

  1. If a transformation requires insertion of one character, it costs 1 point
  2. If a transformation requires deletion of one character, it costs 1 point
  3. If a transformation requires replacement of one character, it costs 2 points, except where the character being replaced and its replacement are adjacent to one another on the same line of a qwerty keyboard, in which case it costs 1 point

These operations can be performed in any order, so for example, to transform the domain name "directi" to "iriecti", we can either do a deletion of "d" in directi followed by an insertion of "i" or perform an insertion followed by the deletion. Similarly, "iriecti" can be transformed to "directi" by performing an insertion of "d" followed by a deletion of "i" or vice-versa.

For all domain name transformations that use 1 or 2 points, we wish to impose a surcharge of 50 and 25 cents respectively. Any domain name that requires more than 2 points will have no surcharge imposed upon them.

Input

The input starts with a line containing 2 space separated integers m & n followed by a blank line. m is the number of already registered domain names. n is the list of names that a customer wishes to register - (1 =< m =< 2500) (1 <= n <= 7000). The next m lines are the already registered domain names. This is followed by a blank line. The next n lines are the list of names to be registered. There will be no space in the domain names, and they will consist only of a combination of lowercase alphabets from a to z and digits. The length of a domain name will be less than 31 characters.

Output

The output must consist of n lines. You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points. The value printed should be the integral part of the sum in case it has a fractional part. If a domain has already been registered, you should output -1.

Example

Input:
6 7

google
yahoo
rediff
rediffmail
direct
directi

direct
gallery
speaker
yahooo
gopgle
drect
direzti

Output:
-1
0
0
50
50
50
25


Author: admin
Date Added: 10-06-2009
Time Limit: 30 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

jaganr @ 20 Jun 2009 01:58 PM

Can someone let me know what input the program failed?

ketansakaria @ 7 Jul 2009 05:15 PM

Can you provie me the Maximum Length of the Registered Domain ?

admin 2 @ 7 Jul 2009 05:28 PM

@Ketan Read the problem statement.

ketansakaria @ 7 Jul 2009 11:19 PM

In the Example above for the transformation of gopgle to google cost 2 point. e.g. replacement for p to o(2nd character). So, the output given above is wrong. it must be 25 for the 5th domain gopgle.

ketansakaria @ 8 Jul 2009 06:53 PM

Can anyone provide some tricky inputs to check my program ?

admin 2 @ 8 Jul 2009 06:57 PM

@ketan
#
# If a transformation requires replacement of one character, it costs 2 points, except where the character being replaced and its replacement are adjacent to one another on the same line of a qwerty keyboard, in which case it costs 1 point

ashokchhilar @ 17 Jul 2009 07:05 AM

in a qwerty keyboard, how do we define adjacency in case of digits ?
Do we look for the row just above "qwertyuiop" or the num pad rows ?

admin 2 @ 17 Jul 2009 05:58 PM

Do not consider the numpad. Consider the digit keys right below the function keys.

ghd @ 21 Jul 2009 02:01 PM

Hi Chef,
I couldn't quite understand the statement you made in the 'Output' section of this problem:
"You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points."
What I understand from this statement is that if 'x' is the domain name that is to be registered and 'Y' is the set of domain names already registred, then I need to print maxSurcharge ( x, Y ) logToBase10 ( x ). Here the function maxSurcharge ( x, Y ) returns the highest surcharge incurred for registering 'x' and logToBase10 ( x ) returns the logarithm to base 10 of the number of all domain names that can be made up from the domain name registered with transformations that cost 1 or 2 points.

ghd @ 21 Jul 2009 02:03 PM

Hi Chef,

I am sorry my previous post had some typos. Please consider this.
I couldn't quite understand the statement you made in the 'Output' section of this problem: "You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points."

What I understand from this statement is that if 'x' is the domain name that is to be registered and 'Y' is the set of domain names already registred, then I need to print maxSurcharge ( x, Y ) logToBase10 ( x ). Here the function maxSurcharge ( x, Y ) returns the highest surcharge incurred for registering 'x' and logToBase10 ( x ) returns the logarithm to base 10 of the number of all domain names that can be made up from the domain name registered with transformations that cost 1 or 2 points.

Warm Regards

ghd @ 21 Jul 2009 02:09 PM

Hi Chef,

I am sorry. My previous post still has the same typos. I am unable to get a PLUS symbol appear in the body of the post. I think the comment section has a limitation of not being able to display a PLUS sign. Neither a newline symbol is displayed. Anyway I wanted to ask whether the output had to be: maxSurcharge ( x, Y ) PLUS logToBase10 ( x ), where PLUS is the addition operation. Please refer to the previous post to know what I refer to by maxSurcharge and logToBase10 functions.

admin 2 @ 29 Jul 2009 10:44 PM

Yes, you are right. PLUS is addition

caesar @ 30 Jul 2009 08:48 PM

Admin:

what about abcde -> abcdf should we treat it as deletion of e and addition of f so that we get 25 surcharge or should we treat it as replacement of e to f which doesnt incur any surcharge?

admin 2 @ 30 Jul 2009 09:06 PM

From the problem statement, it seems that both the scenarios you suggested have the same surcharge of 25

caesar @ 30 Jul 2009 09:15 PM

@Admin:
No if you consider it as replacement of e to f then since e and f are not on same row in qwerty keyboard no rule will apply and surchare remains 0. If you consider it as deletion and addition it will incur surcharge of 25 ( i point for deletion and 1 point for addition)

admin 2 @ 30 Jul 2009 09:17 PM

If a transformation requires replacement of one character, it costs 2 points, except where the character being replaced and its replacement are adjacent to one another on the same line of a qwerty keyboard, in which case it costs 1 point

caesar @ 30 Jul 2009 09:22 PM

Ooops..my mistake..misread that clause..thanx admin

admin 2 @ 30 Jul 2009 09:27 PM

You are welcome :)

caesar @ 30 Jul 2009 10:51 PM

I guess there should be atleast one more example that includes surchare PLUS log10.. The example in the problem doesn't have any log10 component and I am not sure if my output is correct.
For example is 50 is the maximum surcharge on a domain and there are 11 registered domains which can be transformed to this domain with 1/2 points does that mean I need to output 50 PLUS log10(11) that is 51??

admin 2 @ 31 Jul 2009 03:40 PM

@Pradeep: Yes, you are right. You should print 51.

caesar @ 31 Jul 2009 06:13 PM

@Admin: Thanx a lot, seems that worked :P

what should we display if

pegasus @ 18 Aug 2009 08:40 PM
what should we display if input is out of range?

Another question,should there

pegasus @ 18 Aug 2009 08:41 PM
Another question,should there be a newline after we display all outputs?

@Amol No.

admin @ 19 Aug 2009 02:30 AM

@Amol No.

I am using an efficient

pegasus @ 20 Aug 2009 05:13 PM
I am using an efficient string transformation algorithm but I am still exceeding time limit.Can anyone provide a bigger/tricky input for this problem?

We use this problem for

admin @ 20 Aug 2009 07:53 PM

We use this problem for recruitment purposes and as such we can't help you with this one :(

The last domain "direzti" can

wizard @ 21 Aug 2009 10:13 AM
The last domain "direzti" can be converted to an already existing domain "directi" by replacing 'z' with 'c'. And since 'c' and 'z' are on the same line on the keyboard, the transformation can be made with 1 point which means the cost should be 50 cents. Am I missing something here?

The problem doesn't say it is

triplem @ 21 Aug 2009 11:03 AM

The problem doesn't say it is 1 point just if both characters are on the same line. Read it again :)

@Stephen Thanks for the

wizard @ 21 Aug 2009 11:29 AM
@Stephen Thanks for the reply. The problem statement "If a transformation requires replacement of one character, it costs 2 points, except where the character being replaced and its replacement are adjacent to one another on the same line of a qwerty keyboard, in which case it costs 1 point" says 2 points if they are being replaced but 1 if the characters are on the same line. Can u elaborate a bit :)

@Stephen Oops... got it :D

wizard @ 21 Aug 2009 11:30 AM
@Stephen Oops... got it :D

I have two strings tree and

pegasus @ 24 Aug 2009 11:30 PM
I have two strings tree and trew. Will the surcharge be treated 25(deletion of e and insertion of w) or 50 (replacement with two adjacent characters on same row)?

The latter case.

admin @ 25 Aug 2009 01:26 PM

The latter case.

Can some one help me

nandish_83 @ 28 Sep 2009 05:09 PM

Can some one help me understanding the problem.

Say for example directi is registered domain name,

There is a new request for the domain name "sirecti"

This can be done in two ways

1) Replace "i" with "s" which will cost 1 point(Adjacent character)

or

1) Insert "d" and then delete "s" which will cost 1+1= 2 points

There may be n ways to derive. Which once should we consider.

The shortest one.

admin @ 28 Sep 2009 05:11 PM

The shortest one.

Thanks Aniruddha, Please can

nandish_83 @ 28 Sep 2009 06:00 PM

Thanks Aniruddha,

Please can you help with this query.

I understand that the solution is  to correct only once place.

Example

Directi is a registered domain

If there is a request for the name irect,

This can be done by adding D at first and i at last..... This is correction at 2 positions.

Should we consider this case

Your help much appreciated

Nandish

 

Yes, you have to consider

triplem @ 29 Sep 2009 06:00 AM

Yes, you have to consider every possible way of altering the domain. There could be many many ways, and you have to find the way that is shortest.

I have the same question

adave @ 10 Oct 2009 01:02 AM

I have the same question Nischal Shetty had before.

I think direzti needs a replace operation and since c and z are in the same row it will cost 1 point, 50 cents. Please tell me how is it 25 cents?

Thanks

Please re-read the problem

admin @ 10 Oct 2009 05:56 PM

Please re-read the problem statement. I think you are not interpreting it correctly

Hi admin/moderators "You need

mohammad @ 20 Oct 2009 01:35 AM

Hi admin/moderators

"You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log"

Forget the log part for simplicity

consider the case of direzti and directi.

here z and c are not adjacent on the same line so with replacement approach they have 2 points. Since it is maximum surcharge no matter what we'll have 2*25 as base surcharge excluding log.

Then how come it is 25 as output for the example????? 

Any help will be greatly appreciated!!

 

Please re-read the problem

admin @ 20 Oct 2009 04:40 AM

Please re-read the problem statement. You are not interpreting it correctly.

"For all domain name

mohammad @ 20 Oct 2009 08:48 PM

"For all domain name transformations that use 1 or 2 points, we wish to impose a surcharge of 50 and 25 cents respectively."

Sorry my mistake...the surcharge is 25 for 2 points and 50 for one points..for rest it is nothing.

 

Got it now...thanks aniruddh

Hi Admin/Mods, Please tell me

mohammad @ 20 Oct 2009 11:18 PM

Hi Admin/Mods,

Please tell me why my submission is giving compilation error while it compiles fine in my machine. I have compiled and runned using code blocks. It uses g++ only.

In function 'int

admin @ 21 Oct 2009 01:02 AM

In function 'int checkReplacementCase(char*, char*)': /sources/tested.cpp:28: error: 'strlen' was not declared in this scope /sources/tested.cpp:38: error: 'abs' was not declared in this scope /sources/tested.cpp: In function 'int transformCount(char*, char*)': /sources/tested.cpp:63: error: 'strlen' was not declared in this scope /sources/tested.cpp: In function 'void getInput()': /sources/tested.cpp:100: error: 'malloc' was not declared in this scope /sources/tested.cpp:107: error: 'strlen' was not declared in this scope /sources/tested.cpp:108: error: 'strcpy' was not declared in this scope /sources/tested.cpp:115: error: 'strlen' was not declared in this scope /sources/tested.cpp:116: error: 'strcpy' was not declared in this scope /sources/tested.cpp: In function 'void getOutput()': /sources/tested.cpp:132: error: 'strcmp' was not declared in this scope /sources/tested.cpp: In function 'void freeMemory()': /sources/tested.cpp:177: error: 'free' was not declared in this scope /sources/tested.cpp:179: error: 'free' was not declared in this scope

 

These were the errors I got when I tried to compile your code.

I wish we could get info abt

mohammad @ 21 Oct 2009 11:04 PM

I wish we could get info abt the test case that resulted in failure.

Hi admin, I am new to this

mohammad @ 22 Oct 2009 02:47 AM

Hi admin,

I am new to this online judge way to evaluate. what is the meaning of time limit exceeded. Is it that since a program exceeded time limit to return back response it is not evaluated for right or wrong output or time limit exceeded means your output was right and solution is correct but it is not within time constraints.

Pls reply.Thanks in advance

 

TLE means that your program

admin @ 22 Oct 2009 03:04 AM

TLE means that your program did not print the output within the allotted time period. WA means that the output produced by your program does not match with the correct output.

hey can you answer this

paloflat @ 22 Oct 2009 03:18 AM

hey can you answer this question too?

"where can I see the compile error? The yellow triangle is not clickable.."

Currently you cannot. If you

triplem @ 22 Oct 2009 05:13 AM

Currently you cannot. If you are not getting a compile error on your computer, then you are probably using something nonstandard, so it would pay to install the standard version Codechef uses.

uhh.. well I tried to send my

paloflat @ 22 Oct 2009 06:05 AM

uhh.. well I tried to send my code to different websites.. to see... if I get the a compile.. before installing I think it might be worth to try SPOJ ACM.

 

Well I was asking if there is a link like: www.codechef.com/viewrun?id=123123

But thanks for response!

yes... SPOJ is using same

paloflat @ 22 Oct 2009 06:11 AM

yes... SPOJ is using same compiler version...

I have 2 question Directi

sumanta.dey2001 @ 22 Oct 2009 03:59 PM
I have 2 question Directi Admin please answer 6 2 google yahoo rediff rediffmail direct directi redi -- cost is 25 one has to add 2 f's at last rewiffmai cost 0 as d will be replaced by w (not a leyboard replace) and l should be added at last. final conclusion is one has to add the points if it is > 2 cost is 0 otherwise 25 or 50. correct ??? please give me quick reply. thanks in advance

6

sumanta.dey2001 @ 22 Oct 2009 04:02 PM

6 2

google

yahoo

rediff

rediffmail

direct

directi

redi -- cost is 25 one has to add 2 f's at last

rewiffmai cost 0 as d will be replaced by w (not a keyboard replace) and l should be added at last.

 

final conclusion is one has to add the points if it is > 2 cost is 0 otherwise 25 or 50. correct ???

please give me quick reply. thanks in advance

We will fix this soon.

admin @ 22 Oct 2009 04:03 PM

We will fix this soon.

hello codecheff admins I have

sumanta.dey2001 @ 22 Oct 2009 04:31 PM
hello codecheff admins I have this query, please go through and tell me whether I am correct or wrong. 6 2 google yahoo rediff rediffmail direct directi redi -- cost is 25 one has to add 2 f's at last rewiffmai cost 0 as d will be replaced by w (not a keyboard replace) and l should be added at last. final conclusion is one has to add the points if it is > 2 cost is 0 otherwise 25 or 50. correct ??? please give me quick reply. thanks in advance

hello codecheff admins I have

sumanta.dey2001 @ 22 Oct 2009 04:36 PM
hello codecheff admins I have this query,
please go through and tell me whether I am correct or wrong.
6 2
google
yahoo
rediff
rediffmail
direct
directi
redi -- cost is 25 one has to add 2 f's at last
rewiffmai cost 0 as d will be replaced by w (not a keyboard replace) and l should be added at last.
final conclusion is one has to add the points if it is > 2 cost is 0 otherwise 25 or 50. correct ???
please give me quick reply.
 thanks in advance

What you have written in bold

admin @ 22 Oct 2009 04:51 PM

What you have written in bold seems right.

Many Many thanks Aniruddha

sumanta.dey2001 @ 22 Oct 2009 04:54 PM
Many Many thanks Aniruddha

Hi Admin, the email id

mohammad @ 23 Oct 2009 02:26 AM

Hi Admin,

the email id puzzles@directi.com bounces back the mail sent. How do I sent my submission for interview process

Hi CodeChef Admin, In the

devadattas @ 3 Nov 2009 10:21 AM

Hi CodeChef Admin,

In the given example shouldn't the surcharge for "drect" be 50.3010299957 (50 + log 2) instead of 50 as it can be transformed to both "direct" and "directi" with 1 and 2 insertions respectively or are we supposed to round off the figure and output. So should the Input and output be the following or the one given?

Input:
6 7

google
yahoo
rediff
rediffmail
direct
directi

direct
gallery
speaker
yahooo
gopgle
drect
direzti

Output:
-1
0
0
50
50
50.3010299957
25

Please reply asap

Read the section of the

triplem @ 3 Nov 2009 10:29 AM

Read the section of the problem titled 'Output'.

I have read it as it says

devadattas @ 3 Nov 2009 10:39 AM

I have read it as it says "plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points.". See my doubt is for the case of "drect" it can be transformed to "direct" by one insertion of "i" i.e. it gets 1 point again it can be transformed to "directi" by 2 insertions of "i"s i.e. it gets 2 points so "drect" can be transformed to 2 domains with 1 or 2 points so shouldn't the output be (50 + log 2) instead of 2. Am i making any wrong assumptions please clarify?

Are we supposed to take the

devadattas @ 3 Nov 2009 10:41 AM

Are we supposed to take the integral part only?

Ok i got it. I guess I missed

devadattas @ 3 Nov 2009 10:55 AM

Ok i got it. I guess I missed this statement "The value printed should be the integral part of the sum in case it has a fractional part." sorry for the troouble

Dictionary<T,T'> in

sharmisnair @ 5 Nov 2009 10:43 PM

Dictionary<T,T'> in Collections.Generics works with the C# compiler you provide?

I'm getting runtime error and I'm not able to figure out what's wrong. It's working fine with Visual Studio I have.

We use mono. Check if your

admin @ 6 Nov 2009 01:52 PM

We use mono. Check if your code runs when you use it.

@Admins: I would like to see

harshmoorjani @ 11 Nov 2009 04:10 PM

@Admins: I would like to see some more test cases to be added in the problem description above. Present test cases are not enough to cover all cases and so I am not sure why my solution is being marked as "Wrong Answer"... may be its a presentation error... or wrong answer to a corner case... or whatever... but I can't be sure of it.

Sample test cases aren't

triplem @ 11 Nov 2009 04:32 PM

Sample test cases aren't meant to cover all the scenarios; they are solely there to make sure you understood the problem. You are meant to come up with real test cases yourself.

I understand that. But then,

harshmoorjani @ 11 Nov 2009 05:06 PM

I understand that. But then, there has to be something(I mean it could be anything - but something) that tells us whether we are making presentation error or logical error or somthing else.

If the system says its a wrong answer, then more that anything else, I wanna know where I went wrong. I think I covered all possible scenarios and I tried making all kind of corner cases to cover those. For first 2-3 tries, I did miss some scenarios but now when am 99.9% sure I have covered all, still wrong answer. Its sort of irritating. Can't stop thinking what I might be missing... and its taking hellp lot of my time. :(

Also, this is a recruitment

admin @ 11 Nov 2009 05:09 PM

Also, this is a recruitment problem so we can't provide any specific help as such. :(

Well, I am also solving this

harshmoorjani @ 11 Nov 2009 05:14 PM

Well, I am also solving this for recruitment pupose. Just that even in recruitment process not just the final right answer matters, often approches(with minor mistake) are worth a look but unless I submit this 100% correct, no one is gonna look into my resume :)

I just can't think of what I am missing :(

Ok, I think you can tell

harshmoorjani @ 11 Nov 2009 05:23 PM

Ok, I think you can tell atleast this much...

In C++, cin>>M>>N; will work, whether M and N are on same line(space seperated) or on different lines.

But In Java, if they are on same line, then we need to split by spaces are 1 readline... and if they are on different lines, we need to readline 2 times.

What should the case?

PS:

Problem says "The input starts with a line containing 2 space separated integers m & n followed by a blank line."

But the sample Java solution(http://www.codechef.com/help/#hc_solinjav) reads both number as if they are on different lines.

 

Thanks

The input is in accordance

admin @ 11 Nov 2009 05:29 PM

The input is in accordance with the input specifications. So if there are 2 integers separated by a space, then that's how they will appear in the input.

Are there any possible cases,

harshmoorjani @ 11 Nov 2009 06:43 PM

Are there any possible cases, other than:

Insertion                1

Deletion                1

Replacement(adj)            1

Replacement(n.adj)            2

Insertion-Insertion            2

Insertion-Deletion            2

Insertion-Replacement(adj)        2

Deletion-Insertion            2

Deletion-Deletion            2

Deletion-Replacement(adj)        2

Replacement(adj)-Insertion        2

Replacement(adj)-Deletion        2

Replacement(adj)-Replacement(adj)    2

Just a simple yes/no will help.

Thanks

Hi All, I do not understand

sayan_pakhi @ 13 Nov 2009 03:01 PM

Hi All,

I do not understand the last test case-direzti

All score is zero except direct,directi.

For direct score is (1 insertion+1 substitution of 1 pt)= 25

For directi 1 sub only ie 50

so score should be 50

The latter substitution costs

triplem @ 13 Nov 2009 03:32 PM

The latter substitution costs 2 points = 25, not 1 point = 50.

Do we need to check the

sreejith @ 19 Nov 2009 10:54 AM

Do we need to check the domain names for any other values in the name other than low case alphabets & numbers?

The second to last sentence

triplem @ 19 Nov 2009 01:24 PM

The second to last sentence in 'Input' tells you this.

@stephen how later

sayan_pakhi @ 19 Nov 2009 04:00 PM

@stephen

how later substituion 2 points c & z in the same row of keyboard

They are on the same row.

triplem @ 19 Nov 2009 04:19 PM

They are on the same row. That isn't what it says makes it only 1 point.

is this the right way of

sreejith @ 19 Nov 2009 07:15 PM

is this the right way of taking the i/p & givin the o/p ?

 

m<space>n<enter>

<blank line>

1

.        [domain names]

.

.

m

<blank line>

1

.        [typo domain names]

.

.

n

<blank line>

1

.         [cost for regisitring each domain name]

.

.

n_       [and my program ends here]

Yeah. Also make sure that you

admin @ 19 Nov 2009 07:23 PM

Yeah. Also make sure that you test your code against the test input output provided.

Hi admin,   My solution is

hailtheking @ 20 Nov 2009 02:42 AM

Hi admin,

 

My solution is working correctly on my system.but I am getting runtime error when I submit the solution.

I tested it for many test cases and it seems to be working fine.may I know the exact error, or is it exceeding the memory limit.

You probably have some issues

admin @ 20 Nov 2009 02:49 AM

You probably have some issues with the way you handle memory.

@Codechef i have tested my

sreejith @ 20 Nov 2009 01:51 PM
@Codechef i have tested my program for d given i/p cases as well as i have tested it for more than 100 i/p cases. But i am still gettin wrong answer,I am using c . can u tell me what is goin wrong or for how many cases my program has worked

No, as this is a recruitment

admin @ 20 Nov 2009 04:02 PM

No, as this is a recruitment problem, we cannot give out such information.

Hi Admin, I am very new to

RanganathG @ 20 Nov 2009 06:08 PM

Hi Admin,

I am very new to this codechef. I have submitted a solution to the Domain Dilemma problem. The class name and the file name are given the same name by me ... but when i submit the solution i am getting a compilation error :

/sources/Main.java:4: class DomainDilemma is public, should be declared in a file named DomainDilemma.java public class DomainDilemma { ^ 1 error

Though my file name is DomainDilemma.java

can you please let me know why is it happening so?

Thanks

 

Class name should be Main.

admin @ 20 Nov 2009 06:48 PM

Class name should be Main. Please read the FAQ and the Sample Solutions

Hi Admin, Is there any line

vikash goyal @ 21 Nov 2009 12:47 AM

Hi Admin,

Is there any line after given "n" number of domains(required domains)?

Hi all, I solved the problem

sayan_pakhi @ 27 Nov 2009 06:00 PM

Hi all,

I solved the problem Needlemen-Wunsch algorithm. I am getting time-out solution.

1. Is it possible to get accepted solution through Needlemen-Wunsch algorithm?

I optimised my code enough. Please give me a hints.

Hi all, I am waiting for your

sayan_pakhi @ 28 Nov 2009 01:23 PM

Hi all,

I am waiting for your valuable comments.

Is it possible to get accepted solution through Needlemen-Wunsch algorithm?

As mentioned many times

triplem @ 28 Nov 2009 02:18 PM

As mentioned many times already in the above comments, this is a recruitment problem. You will not be given hints.

wat do we mean by adjacency?

anirudha.ptr @ 17 Dec 2009 10:05 AM

wat do we mean by adjacency? are 'h' and 'y' adjacent?

"You need to print the

anirudha.ptr @ 17 Dec 2009 10:13 AM

"You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points."

Please help me understand the output:

for the input drect, we could transform it using any of the following ways:

a) delete any character: 5 ways

b) insert a new character anywhere: 6*36 ways (because there are 36 new characters and we could insert it in any of the 6 positions.

c) delete any two characters: C(5,2) ways

d) insert any two characters :

e) replace any two characters with their adjacent characters on a keyboard.

f) replace a single character with a non adjacent character.

So, the answer should be 50 plus log(sum of all these possibilities) which sure will be greater than 100, so , the answer should be at least 52.

Please clarify whether the answer or my understanding is flawed.

 

h and y are adjacent, but

triplem @ 17 Dec 2009 10:59 AM

h and y are adjacent, but they aren't on the same line.

It doesn't tell you to take the log of the number of ways you could transform it, but the number of domains you could transform it to. There is only one; 'direct'.

ok. thanks for the help

anirudha.ptr @ 17 Dec 2009 12:07 PM

ok. thanks for the help

i am not able to submit a

anirudha.ptr @ 17 Dec 2009 09:38 PM

i am not able to submit a solution. it is sayin contest_problem_id required??

Log out and login

admin @ 17 Dec 2009 09:41 PM

Log out and login

Is the empty string a valid

chaprajilla @ 22 Dec 2009 04:24 AM

Is the empty string a valid string that the customer can try to register? Technically the problem description does not rule this case out :)

There will be no space in the

admin @ 22 Dec 2009 03:11 PM

There will be no space in the domain names, and they will consist only of a combination of lowercase alphabets from a to z and digits. The length of a domain name will be less than 31 characters.

"You need to print the

hemang.rm @ 22 Dec 2009 10:11 PM

"You need to print the maximum surcharge incurred for registering a particular domain when compared with all the already registered domain names plus the log to the base 10 of the number of domain names that this domain name could be transformed to by using 1 or 2 points." If the no. of domain names that this domain name could be transformed to by using 1 or 2 points is zero (e.g. speaker and gallery in test input) then log to the base 10 of zero is I hope not something we are looking forward to.

So perhaps problem statement needs a mention of the fact that in case where there is not a possible transformation with even one registered domain, then log has to be avoided and surcharge has to be 0. I understand that test example does hint that.

Please correct me if I have misunderstood something.

I have tried two solutions for this problem, using dynamic programming that exceeds time limit and non DP solution that gives "wrong answer" although it runs successfully on my machine for all possible test cases that I can imagine. Please help.

 

That is clear from the

admin @ 22 Dec 2009 10:25 PM

That is clear from the example test cases that have been provided.

Does "time limit exceeded"

hemang.rm @ 27 Dec 2009 02:09 AM

Does "time limit exceeded" mean that code ran suceessfully for all test cases and produced correct output, but did not run in time limit ?  or it does not guarantee correct output for all test cases.

It means the time limit was

triplem @ 27 Dec 2009 02:44 AM

It means the time limit was exceeded. If it didn't finish running, how could it know whether it was correct or not?

Hi, can the admin tell

gaurav_kl @ 28 Dec 2009 08:40 PM

Hi,

can the admin tell whether there is an error in the format of my input-output or is there something wrong with the answer??

the output is correct on my compiler and its working for the sample test cases given in the problem.

Plz tell whether my solution

gaurav_kl @ 30 Dec 2009 12:44 AM

Plz tell whether my solution has problem in the format of input-output or is there problem with some test-case.

I hv tried so many times and my code is giving the correct output for any test-case in my compiler.

High quality low price,all

gogo500go @ 2 Aug 2010 07:22 AM

High quality low price,all types of High Heel Shoes , Jimmy Choo Shoes is one of classic Manolo Blahnik boots chapa gtx. can lose your weight juse by walking.Come on and try YSL Shoes now!

SUCCESSFUL SUBMISSIONS


Fetching successful submissions

HELP



Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.

  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.

  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.

  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.

  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

  • If you are still having problems, see a sample solution here.
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.