Page 13 of 15

Re: 490 - Rotating Sentences

Posted: Fri Jul 12, 2013 3:38 pm
by hello
Thanks for your reply . . . . . . .

490 - Rotating Sentence

Posted: Wed Jul 24, 2013 1:35 pm
by marufsharif
.

Re: 490 - Rotating Sentence

Posted: Wed Jul 24, 2013 11:03 pm
by brianfry713
For the sample input, there should be a space at the end of the last two lines of the output.

Re: 490 - Rotating Sentence

Posted: Thu Jul 25, 2013 9:45 am
by marufsharif
thanks

Re: 490 - Rotating Sentence

Posted: Sat Jul 27, 2013 12:20 am
by brianfry713
Print a newline at the end of the last line.

Re: 490 - Rotating Sentence

Posted: Sun Jul 28, 2013 7:28 am
by marufsharif
Post Remove, After Accept

Re: 490 - Rotating Sentence

Posted: Mon Jul 29, 2013 4:46 am
by brianfry713
Try input:

Code: Select all

1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

Re: 490 - Rotating Sentence

Posted: Mon Feb 17, 2014 7:24 pm
by Shihab
PE !

Code: Select all

#include<stdio.h>
#include<string.h>

int main()
{
    int i=0,j,temp,max_len=0;

    char string[101][101];

    while(gets(string[i]))
    {
        if(strlen(string[i])>max_len)
            max_len=strlen(string[i]);

        i++;
    }

    temp=i;

    j=0;

    while(j<max_len)
    {
        i=temp;

        while(i>=0)
        {
            if(j>=strlen(string[i]))
                printf(" ");
            else
                printf("%c",string[i][j]);
            i--;
        }

        printf("\n");

        j++;
    }

    return 0;
}


Re: 490 - Rotating Sentence

Posted: Tue Feb 18, 2014 8:44 pm
by brianfry713
For the sample input, don't print a space at the beginning of every line.

Re: 490 - Rotating Sentence

Posted: Sat Feb 22, 2014 1:15 pm
by uDebug
As brianfry713's mentioned, unfortunately, the sample output's faulty. (On the input, Decartes's mispelled - it should be "Descartes". Though this isn't critical to solving the problem.)

Input:

Code: Select all

Rene Decartes once said,
"I think, therefore I am."
AC Output:

Code: Select all

"R
Ie
 n
te
h 
iD
ne
kc
,a
 r
tt
he
es
r 
eo
fn
oc
re
e 
 s
Ia
 i
ad
m,
. 
" 

Re: 490 - Rotating Sentence

Posted: Sat Feb 22, 2014 1:22 pm
by uDebug
Here's some input / output to make things clearer in regards to the spaces.

Input:

Code: Select all

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque a sem euismod magna consequat 
sodales. In mollis fringilla volutpat. Ut ut condimentum nulla, ac tincidunt lectus. Mauris a 
rhoncus enim. Vivamus tincidunt arcu mi, sit amet feugiat turpis suscipit vel. Nulla convallis 
Quisque id lacus at nulla laoreet malesuada vitae aliquam tellus. Pellentesque vehicula laoreet
feugiat nulla, vel tristique augue egestas vel. Curabitur pretium mauris cursus dolor tristique 
lobortis. Morbi mollis bibendum ante eget pharetra. Donec eu lorem leo. Vestibulum ante ipsum 
primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam hendrerit arcu a porta 
venenatis. Cras ornare ipsum ac dolor congue auctor. Phasellus vitae placerat sem. Ut et lorem 
quam. Donec suscipit turpis a eros ullamcorper, vitae lobortis eros sodales. Cras lorem odio, 
sollicitudin a rhoncus in, cursus vitae lorem. In feugiat posuere fermentum. Nulla lacus metus, 
sagittis et lacus nec, accumsan fringilla libero. Nam in est et odio cursus vestibulum. Duis nec
AC Output:

Code: Select all

ssqvplfQrsL
aoueroeuhoo
glanibuiodr
ilmemogsnae
ti.niriqclm
tc astauue 
iiDt itessi
stoiis   .p
 unsn.nie s
ede.  udnIu
tic fMl inm
 n Caollm  
l sruraa.md
aauacb,c oo
c ssii uVll
urc b vsilo
shioume vir
 oprsolaas 
nnin l tm s
ectaolt ufi
cu rrirnsrt
,stecsiu i 
  u i sltna
airi btligm
cnppliianie
c,isubq clt
u suceulil,
mc mtneada 
sua ud ou c
ar asuarnvo
nsec mueton
 ur e ge ls
fsodtautaue
r so ne rtc
iv lut mcpt
niuoleeauae
gtlrt gl tt
ial reeem.u
leacigssi r
l mocetu,U 
alcnetaa ta
 oogs sds d
lrru p aiui
iepephv ttp
bme oaev  i
e.rasrliacs
r ,uue.tmoc
oI cet aeni
.nvtrrCetdn
  ioeau  ig
Nftr .rafm 
aea.c aleee
mue uDbiunl
 g Pboiqgti
iilhintuiut
naoaleuaam.
 tbsicrmt  
e oea    nQ
sprl epttuu
totlCureuli
 siuu elrls
eussrltlpaq
te  aoiui,u
 reveruss e
oeri;em. a 
d ot m  sca
ifsaE mPu  
oe etlaests
 rs ieulcie
cmopaorlinm
uedlm.iepc 
rnaa  sniie
stlchV ttdu
uueeeece ui
smsrnsusvns
 ..adtrqetm
v  trisul o
eNC ebue.ld
sursrus  e 
tlaeil vNcm
ilsmtudeuta
ba . mohlug
u l a lilsn
lloUraoca.a
uartcnru   
mce ut lcMc
.ume etaoao
 s ta r nun
D o  iilvrs
umdlppsaaie
ieioostolsq
storruirl u
 u,etmqeiaa
ns ma ues t
e,    et   
c          
           

Re: 490 - Rotating Sentence

Posted: Sat Mar 08, 2014 6:11 am
by s.mahzabin
I'm getting WA. :(
Here's my code.. What's wrong with it? :-?

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
	char s[102][102],found;
	int i,j,len,maxl;
	for(i = 0; i < 102;++i)
	{
		for(j = 0; j < 102; ++j)
			s[i][j] = ' ';
	}
	for(i = maxl = 0;gets(s[i]);++i)
	{
		if(strlen(s[i]) > maxl)
			maxl = strlen(s[i]);
	}
	len = i-1;
	for(j = 0,found = 1; found == 1; ++j)
	{
		for(i = len,found = 0; i >= 0; --i)
		{
			if(j < maxl)
			{
				found = 1;
				putchar(s[i][j]);
			}
		}
		if(found == 1)
			putchar('\n');
		
	}
	return 0;
}

Re: 490 - Rotating Sentence

Posted: Sat Mar 08, 2014 9:21 am
by uDebug
s.mahzabin wrote:I'm getting WA. :(
Here's my code.. What's wrong with it? :-?
Your code fails on the sample input (given in the problem statement). Try taking the sample input provided two posts above yours and run your program. Compare the output with the AC output provided.

Also, next time, consider reading the thread carefully. It exists for a reason. Often times, you'll find useful information - including test cases that others have posted.

Re: 490 - Rotating Sentence

Posted: Fri May 09, 2014 9:04 am
by johncip
Anyone know if it's necessary to actually read in the newlines (like maybe the judge input has a mix of lines with and without carriage returns)?

I'm doing it in Java and my output matches the sample output, with spaces to pad the ends of output lines (that is, I'm printing a perfect rectangle, bound by the number of lines read in and the length of the longest line read in).

I've tried it a number of ways: without the padding at the ends of lines, with an extra newline at the end, with an extra line of spaces at the end (like in your sample output, v1n1t -- should there be an extra space at the end of the last line in your input? I'm confused), and nothing seems to work.

Closest I came was when I actually had a bug (wasn't printing spaces on the left when ending input rows are short) and I got PE. But I feel like I've tried it every which way at this point, short of trying to save the newline characters, and nothing's passed. I think on my next attempt I'm going to make sure I'm going to use OS-dependent newline behavior, but I've never had to do that before, and don't know what else it could be.

I'm using diff to test my output, so I don't think there are any stray null characters.

If anyone's interested, my code is here: https://gist.github.com/johncip/9de5a3bbaea4225f34bc
(This version does not print an extra line at the end.)

Nevermind, just realized it doesn't work with brianfry's input (skips the zeros!?). Off to figure out why...

Re: 490 - Rotating Sentence

Posted: Fri May 09, 2014 9:26 am
by uDebug
johncip wrote:I've tried it a number of ways: without the padding at the ends of lines, with an extra newline at the end, with an extra line of spaces at the end (like in your sample output, v1n1t -- should there be an extra space at the end of the last line in your input? I'm confused), and nothing seems to work.
Hang in there. It can be very frustrating when the problem's straightforward and getting the output right's a challenge.

I did a cursory check and your code looks good. I'm sorta pressed for time and can't debug in detail now but I'll circle back later (and try to provide an answer to your question).

Just wanted to tell you to keep the faith. It'll work out. Sometimes trying something else in the meantime really helps.

EDIT:
Nevermind, just realized it doesn't work with brianfry's input (skips the zeros!?). Off to figure out why...
Yep. Just now saw that too. It does work fine though if the input's like so

Input:

Code: Select all

Rene Decartes once said,
"I think, therefore I am."
a
b
abcd
abcdefghijklmnopqrstuvwxyz
hellobonjourholanamaskaramnihao
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890