Page 5 of 9

Posted: Wed Aug 16, 2006 3:42 pm
by Bluefin
I just solved this problem today ~~
I didn't read your code but I compared the output from your program with
my ACC one.

my output is

Code: Select all

I evol .uoy
uoY evol .em
er'eW a yppah .ylimaf
while yours is

Code: Select all

I evol .uoy
uoY evol .em
er'eW a yppah .ylimaf
-----------> there is a blank line
But this may only cause PE ~~
But I tell you so once you get rid of WA you can get ACC without PE

BTW I use getchar to solve this problem in 0.000 second!!
If you want to try a different approach, that's the way!!

Hope this will help you ~~ :D

Posted: Wed Aug 16, 2006 5:18 pm
by jan_holmes
I have modified your code a bit... it is AC now... Here it is :

Code: Select all

#include <string> 
#include <cstring> 
#include <iostream> 
//#include <fstream> 
#include <stack> 
using namespace std; 

int main() 
{ 
//   ifstream fin("input.txt"); 
   stack<char> stk; 
   string str; 
   int count = 0;
   while (getline(cin, str)) { 
         if (count) cout << "\n";
      for (int i  = 0; i < str.length(); i++) { 
         if (str[i] != ' ') { 
            stk.push(str[i]); 
         } 
         else { 
            while (!stk.empty()) { 
               cout << stk.top(); 
               stk.pop(); 
            } 
            if (str[i] == ' ') 
               cout << ' '; 
         }
         count++;
      } 
      while (!stk.empty()) {
            cout << stk.top();
            stk.pop();
      }
   } 
   return 0; 
}

483...why presentation error?

Posted: Wed Aug 23, 2006 4:46 pm
by Iffat
:oops: i can't understant why i got presentation error....

Code: Select all

c#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX 50000

int main()
{
	long i,j,l,n;
	char ch,str[MAX],str1[MAX];
	
	while(scanf("%s",&str)!=EOF)
	{
		l=strlen(str);
		for(i=0,j=l-1;i<l,j>=0;i++,j--)
			{
				str1[i]=str[j];
						
			}
			
		printf("%s",str1);
		scanf("%c",&ch);
		printf("%c",ch);
		for(n=0;n<l;n++)str1[n]='\0';
		
			
	}
	
				
	
	return 0;
}
plzz help me :(

483 ?? Wrong Answer.. help me!!

Posted: Thu Aug 24, 2006 4:59 am
by clove
it's my code.
it code Wrong Answer..

[483] tab key application??

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

void main()
{
char a[100000];
int temp[100000];

int ns;
int count;
int i,j;

while( gets(a) != NULL )
{

ns = strlen(a);

count = 1;

temp[0] = 0;

for( i = 0 ; i <=ns ; i++ )
if( a[i]==' ' || a[i]=='\0')
{


temp[count] = i;

count=count-1;


if( count==0 )

{
for( j = i-1 ; j >= temp[count] ; j-- )

printf("%c",a[j]);

count=count+2;
}
else
{
for( j= i ; j > temp[count] ; j-- )

printf("%c",a[j]) ;

count=count+2;

}


}

printf("\n");
}
}

Posted: Wed Feb 14, 2007 4:12 am
by soyoja
You must remove only last blanks, and other blanks must same as input string.

For example,

Input ( _ means blank )

Code: Select all

__I___love_you.___ 
Presentation Error

Code: Select all

__I___evol_.uoy___ 
Accepted

Code: Select all

__I___evol_.uoy
Good luck.

Posted: Wed Feb 14, 2007 4:19 am
by soyoja
Your progam prints wrong blanks...
You must remove only last blanks, and other blanks must same as input string.

For example,

Input ( _ means blank )

Code: Select all

__I___love_you.___ 
Presentation Error

Code: Select all

__I___evol_.uoy___ 
Accepted

Code: Select all

__I___evol_.uoy
Good luck.

why PE?()483

Posted: Tue Feb 20, 2007 2:27 pm
by ishtiaq ahmed
I cannot understand why this easy problem hangs me on presentation error? Can anybody help me?plzzzzzzzzz

Code: Select all

The code is removed after AC.

Posted: Thu Feb 22, 2007 2:49 pm
by Jan
soyoja wrote:You must remove only last blanks, and other blanks must same as input string.
For the
Input:

Code: Select all

__I___love_you.___ 
My accepted code returns
Output:

Code: Select all

__I___evol_.uoy___
So trailing blanks may not be the actual problem.

message of 383

Posted: Sat Feb 24, 2007 6:08 am
by ishtiaq ahmed
thank you Mr.Jan.I got AC. :P

483 Word Scramble PE!!!!!!!!!!!!!

Posted: Tue Feb 27, 2007 2:34 am
by x140l31
I don't know why I have PE.

I tried all the possibilities that I found in the forum... removing the lasts blanks... without removing them... removing the last blank line...

I need help please :(

Can someone give me an input sample or send me a mp with the correct code in C++? :(

thx!

P.D.: sorry if my english is bad... jeje

Posted: Wed Mar 07, 2007 7:14 pm
by Debashis Maitra
Post output part of your code
then anyone can help you

problem says output should be
I evol .uoy<== new line
uoY evol .em<== new line
er'eW a yppah .ylimaf<== new line
<==cursor is here but no new line
Best of luck

Posted: Tue May 15, 2007 1:53 pm
by x140l31
This is my code:

Code: Select all

#include <iostream>
#include <string>
#include <sstream>
using namespace std;  
int main() {	
    string line;	
    while (getline(cin, line)) {		
          for (int i = 0; i < (int)line.size(); ++i) {			
              if (line[i] == ' ') cout << " ";			
              else {				
                   string word;				
                   while (line[i] != ' ' and i < (int)line.size()) {					
                         word = line[i] + word;					
                         ++i;				
                   }				
                   cout << word; 				
                   if (line[i] == ' ') cout << " ";			
              }		
          }		
          cout << endl;	
    }
} 
:(

PE in prob 483

Posted: Sun May 27, 2007 11:29 pm
by That's Good
It's not difficult to get PE in this prob. It usually happens.

In your code you defined the space twice one in if and another in outside else within the same for loop. Here I think the matter U can get PE. U better check that again. I think that will help now. :wink:

Posted: Wed Jun 06, 2007 3:30 am
by NaIx
somebody help plzz... i got WA... i don't know why i got WA.......

Code: Select all

#include<cstdio>
#include<cstring>
#include<cstdlib>
#define MAX 1000000

int main()
{
    char kata[MAX];
    long int start, end, len, i, j;
    while(gets(kata))
    {
        len=strlen(kata);
        start=end=0;
        for(i=0;i<len;i++)
        {
            if(kata[i]!=' '&& kata[i]!='.')
                end++;
            else if(kata[i]==' ')
            {
                for(j=end-1;j>=start;j--)
                {
                    printf("%c",kata[j]);
                //    system("pause");
                }    
                start=end;
                if(kata[start]==' ')
                {
                    printf(" ");
                //    system("pause");
                    start++;
                    end=start;   
                }
            }
            else if(kata[i]=='.')
            {
                for(j=end;j>=start;j--)
                {
                    printf("%c",kata[j]);
                //    system("pause");
                }    
                start=end;
           }
        }
        printf("\n");
    }
    return 0;
}

Posted: Wed Jun 06, 2007 11:45 am
by Jan
Try the cases.

Input:

Code: Select all

This is the problem!!!
My email is a@aa@aaa.com@
Output:

Code: Select all

sihT si eht !!!melborp
yM liame si @moc.aaa@aa@a
Hope these help.