490 - Rotating Sentences

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
User avatar
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

490 PE again!

Post by Donotalo » Tue Aug 01, 2006 2:50 pm

here is my output code. i'm getting PE. please help me!

Code: Select all

b = false;
for (k = 0; k < max; k++) {
	if (b) cout << endl;
	for (b = false, j = i-1; j >= 0; j--) {
		if (table[j][k]) {
			cout << table[j][k];
			b = true;
		}
		else cout << ' ';
	}
}
Image

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Tue Aug 01, 2006 3:58 pm

newline at end of file as far as I can tell.

User avatar
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

Post by Donotalo » Tue Aug 01, 2006 7:42 pm

correct me if i'm wrong. here is a sample input and output. the output starts after the line ^Z.

Code: Select all

ab
cdefgh
hijk
^Z
hca
idb
je
kf
 g
 h 
Image

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Tue Aug 01, 2006 8:51 pm

Hmm, no newline at the end of the output? Haven't tried my hand at this one but it looks really easy so if I get around to it (working on a few others at the moment), I'll let you know.

BTW, it *might* be throwing garbage in the input, which you should ignore. ie, "this\t\is" should return:

t
h
i
s

i
s

and not:

t
h
i
\t
is

I've only done about 20 since the 23rd of July, and every time I get PE it's something silly with the input/output, garbage text or something unexpected in the input. They like to trick you up.

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Tue Aug 01, 2006 10:07 pm

edit: trailing spaces are "okay" (and possibly expected), haven't tried writing a "strip trailing spaces" function, but I might if I get bored.

This was a cool and easy problem.
Last edited by sml on Wed Aug 02, 2006 7:34 am, edited 1 time in total.

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Wed Aug 02, 2006 7:30 am

Erm. Screw all that crap I was writing. I got AC, the problem is that it expects a newline at the end of the output! Grr! I would've got it on my first try had I done that.

I hate this! Die PE die!

User avatar
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

Post by Donotalo » Wed Aug 02, 2006 8:16 pm

i tried all the combinations of a blank line:

* at the beginning of the first output
* at the end of the last output
* both at the beginning and at the end of the output

all i got is a PE!

ps: TABS (\t) are not legal characters for this problem.
Image

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita » Wed Aug 02, 2006 9:42 pm

even i am getting PE....although my code do not output space at the end..something else is amiss..

Code: Select all

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    vector<string> v;
    string s;
    vector<int> vi;
    while (getline(cin,s))
    {
          v.push_back(s);
          }
          int m=0;
          for (int i=0;i<v.size();i++)
          {
              vi.push_back(v[i].size());
              if(v[i].size()>m)
              m=v[i].size();
              }
              int c=0;
              while (c<m)
              {
                    for (int i=v.size()-1;i>=0;i--)
                    {
                         if(vi[i]>c)
                         cout<<v[i][c];
                         }
                         
                         if(c!=m-1)
                         cout<<endl;
                         c++;
                         }
                         return 0;
                         }
                         
:cry: help...
win

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Thu Aug 03, 2006 8:06 am

Do you or do you not have trailing spaces? My output does, and I got AC. Do a forum search for this problem, there are some sample data to try.

sml
New poster
Posts: 15
Joined: Mon Jul 24, 2006 3:34 pm

Post by sml » Thu Aug 03, 2006 8:18 am

It needs trailing spaces as far as I understand.

User avatar
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

Post by Donotalo » Fri Aug 04, 2006 7:37 am

got accepted. the judge was looking for trailling spaces as well as a newline at the end of the output.
Image

razor_blue
New poster
Posts: 27
Joined: Mon Nov 27, 2006 4:44 am
Location: Indonesia

Post by razor_blue » Thu Dec 07, 2006 4:03 am

Can someone tell me, what's wrong with my code?

Code: Select all

/* removed after AC */
Last edited by razor_blue on Thu Dec 07, 2006 10:16 am, edited 1 time in total.

mogers
New poster
Posts: 29
Joined: Tue May 30, 2006 5:09 pm
Location: Porto, Portugal

Post by mogers » Thu Dec 07, 2006 4:38 am

I think that you didnt read the problem well.

try this input:

Code: Select all

amen!
CCCCCCC
BBBB
AAAAAA
DD
E
"Mike"
The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.
can you figure out whats wrong in your program ?
Miguel Oliveira

razor_blue
New poster
Posts: 27
Joined: Mon Nov 27, 2006 4:44 am
Location: Indonesia

Post by razor_blue » Thu Dec 07, 2006 10:14 am

I tried that input and my code produce:

Code: Select all

"EDABCa
M DABCm
i  ABCe
k  ABCn
e  A C!
"  A C 
     C 

Thank you mogers, but I think my output is correct.
I just enlarge the size of array and post again that code.
And suprisely, I got AC.

User avatar
dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm

GOT PE

Post by dust_cover » Mon Dec 11, 2006 10:19 pm

hi donotalo,

what did you mean by trailing spaces?
I read the previous topics but I could not get you!
Can you please explain me a lil bit?

---thnx in advance!
i wanna give it a try....

Post Reply

Return to “Volume 4 (400-499)”