Page 5 of 15

490 PE again!

Posted: Tue Aug 01, 2006 2:50 pm
by Donotalo
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 << ' ';
	}
}

Posted: Tue Aug 01, 2006 3:58 pm
by sml
newline at end of file as far as I can tell.

Posted: Tue Aug 01, 2006 7:42 pm
by Donotalo
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 

Posted: Tue Aug 01, 2006 8:51 pm
by sml
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.

Posted: Tue Aug 01, 2006 10:07 pm
by sml
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.

Posted: Wed Aug 02, 2006 7:30 am
by sml
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!

Posted: Wed Aug 02, 2006 8:16 pm
by Donotalo
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.

Posted: Wed Aug 02, 2006 9:42 pm
by vinit_iiita
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...

Posted: Thu Aug 03, 2006 8:06 am
by sml
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.

Posted: Thu Aug 03, 2006 8:18 am
by sml
It needs trailing spaces as far as I understand.

Posted: Fri Aug 04, 2006 7:37 am
by Donotalo
got accepted. the judge was looking for trailling spaces as well as a newline at the end of the output.

Posted: Thu Dec 07, 2006 4:03 am
by razor_blue
Can someone tell me, what's wrong with my code?

Code: Select all

/* removed after AC */

Posted: Thu Dec 07, 2006 4:38 am
by mogers
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 ?

Posted: Thu Dec 07, 2006 10:14 am
by razor_blue
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.

GOT PE

Posted: Mon Dec 11, 2006 10:19 pm
by dust_cover
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!