SPOJ Problem Set (classical)

2523. Mispelling

Problem code: GNY07A

Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string.

Input

The first line of input contains a single integer N (1 ≤ N ≤ 1000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing M, a space, and a string made up of uppercase letters and spaces only. M will be less than or equal to the length of the string. The length of the string is guaranteed to be less than or equal to 80.

Output

For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the misspelled string. The misspelled string is the input string with the indicated character deleted.

Sample Input

4
4 MISSPELL
1 PROGRAMMING
7 CONTEST
3 BALLOON

Sample Output

1 MISPELL
2 ROGRAMMING
3 CONTES
4 BALOON

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 08, 2011

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

My code is returning correct output for all the cases discussed here. But still, I am getting WA. Can someone please check my code to give me some hint?

Our apologies. You were being bitten by the fact that this file used CRLF endings instead of LF endings. This doesn't affect most people, because they read in the number before using getline for the string, but you parse the number manually. (Using cin.ignore(#, '\n') works.)

I've fixed the test data and rejudged your submission, which now gets AC.

Thanks for checking and correcting.

My output is
4MISPELLROGRAMMINGCONTESBALOON
. Can anyone give me a hint to what is wrong with my code?

You are not outputing on the next line. angel.gif

my code gave the right outputs on my computer but I get RE when I submit? And what's a decimal integer...?

1. Please read the input format more carefully.
2. Here, "decimal" refers to the numerical base--contrast with octal, or hexadecimal. Decimal means base 10, so just use the normal numbers you're familiar with.

Sorry for disturbing, but the judge is returning some runtime error and I cannot see the whole of it because it is getting clipped. Could you please check my code and tell me where I am going wrong. I am getting correct output on my machine though. :)

Traceback (most recent call last): 
File "a.out", line 5, in <module>
(snip)
ValueError: too many values to unpack

the input though...

Can someone check out my code please. I get 90/100 and right now I am at lost as to where the error might be. Thanks for any help.

Read the question again. The only reason you're getting 90/100 instead of 20/100 is because the test data is a little weak :) Oops. Misread your code. Retracted.

My test input:

10
4 MISSPELL
1 PROGRAMMING ASDF
7 CONTEST ASDF ASDF
3 BALLOON
11 HELLO BELLO HOWDY
5 WHAT IS THE
6 MEAINNIG BLABLA
15 BATMAN SUPERMAN
12 WOLOLOL LOLO
13 GOOAL A B C D


Output:
1 MISPELL
2 ROGRAMMING ASDF
3 CONTES ASDF ASDF
4 BALOON
5 HELLO BELL HOWDY
6 WHATIS THE
7 MEAINIG BLABLA
8 BATMAN SUPERMA
9 WOLOLOL LOL
10 GOOAL A B C

Sorry for beeing slow but I've read the problem quite a few times and tested it aswell, for example here is my test output, and I don't see what is wrong with it.

When testing, it's often a good idea to try edge cases. What happens when the string is min (1) or max (80) length?

Okay, thank you for the help, first thing tomorrow i'll put more thought into the edge cases! Thanks again!

Ok, its me again... sorry for bothering again.
I've tried the cases you have mentioned. I think I'm getting the right output, though maybe the format is not good. Can you take a look at it?

My Input:
6
4 MISSPELL
1 P
3 EGY JETTO
7 CONTEST ASDF ASDF
3 BALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONO
1 W

Output:

1 MISPELL
2
3 EG JETTO
4 CONTES ASDF ASDF
5 BALOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONOBALLOONONO
6

Your output format is fine; your output is just wrong (though not for those cases). You're still missing an edge case. :)

My code is returning correct outputs in the above cases and the submitted test case. However, it still says it is 60/100.

Try coming up with some of your own cases. In particular make one or two with longer strings and larger values of n. The issue will become clear.

Also, see this link and read the Important Note: http://wcipeg.com/wiki/Judge:Help#Guidelines_for_submitting

I'm not sure what's wrong

Each dataset consists of a single line of input containing M, a space, and a string made up of uppercase letters and spaces only.

My code works perfectly with the test cases, and the one with the spaces mentioned above in the comments. However, I am getting a score of 0. Any reasons as to why this is?

Your code outputs:
1 null COLUR

when the correct answer is:
1 COLOR

You should also read these guidelines -- specifically, the important note.

It's likely that you're doing Something Bad that is corrupting memory and giving you the nulls. In particular, in one case your output contains no space at all, which looks impossible given your code... right?

See also this section of the wiki.

Thanks guys. I pasted my code instead of submitting the file, and it worked. I got 100/100.

I submitted the wrong file (2 a1.java files). Sorry!

So you've said that the input string will contain spaces. Does that mean we should include the space as a char to remove or just take the first word before the space?

A test case may be:
2 
3 THIS IS A TEST
5 JUST CHECKING

for which the output would be:
1 THS IS A TEST 
2 JUSTCHECKING

alright thanks I got it now.