Page 2 of 4

Posted: Wed Sep 19, 2007 8:42 am
by lnr

Code: Select all

Changed

Posted: Wed Sep 19, 2007 12:18 pm
by Jan
In my gcc, your code doesn't even pass the samples. And read the description again
You must print a blank line between each test case.
You missed this line, too.

Hope these help.

Posted: Wed Sep 19, 2007 7:00 pm
by lnr

Code: Select all

Changed

Posted: Thu Sep 20, 2007 1:22 am
by Jan
Your code prints only the 'caseno'. I have tried both gcc and ms vc. Add the following part...

Code: Select all

   cin>>test;
//   {
      cin.get(); // to eliminate the newline after test
      cin.get(); // for the blank line
      for(i=1;i<=test;i++)
And then check the second sample very caerfully. Your code fails. Hope it helps.

Posted: Thu Sep 20, 2007 6:05 am
by lnr

Code: Select all

Changed

Posted: Thu Sep 20, 2007 8:18 am
by Jan
Almost correct. But missing some conditions. Try the cases..

Input:

Code: Select all

2

   allwords   
and 

and
abc
Output:

Code: Select all

Case #1:
a
a

Case #2:
a
a
Hope these help.

Posted: Thu Sep 20, 2007 3:45 pm
by lnr

Code: Select all

Canged

WA

Posted: Tue Oct 30, 2007 7:41 pm
by himanshu
Please help me with this. I have tried samples posted in this thread. Judge gives me WA

Code: Select all

#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main()
{
	int T;		
	cin >> T;
	string s;
	getline(cin, s);	
	getline(cin, s);
	for(int i = 1; i <= T; i++)
	{	
		cout << "Case #" << i << ":" << endl;
		while(getline(cin, s))
		{

			if(s == "")	
			{
				cout << endl;
				break;
			}

			istringstream sin(s);			
			string w;
			for(int j = 0; sin >> w;)
				if(j < w.size())
					cout << w[j++];
			cout << endl;
		}
			
	}
	return 0;
}
Thank You,
HG

Re: 11220 - Decoding the message

Posted: Tue Jul 29, 2008 1:56 pm
by lnr
Thanks Jan.
Finally I got AC.
Your input helped me a lot.
You are a great helper.

Re: 11220 - Decoding the message

Posted: Tue Jul 29, 2008 2:00 pm
by lnr
himanshu wrote:
Please help me with this. I have tried samples posted in this thread. Judge gives me WA
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main()
{
int T;
cin >> T;
string s;
getline(cin, s);
getline(cin, s);
for(int i = 1; i <= T; i++)
{
cout << "Case #" << i << ":" << endl;
while(getline(cin, s))
{

if(s == "")
{
cout << endl;
break;
}

istringstream sin(s);
string w;
for(int j = 0; sin >> w;)
if(j < w.size())
cout << w[j++];
cout << endl;
}

}
return 0;
}
Thank You,
HG
I got accepted using C language functions.
I ran your code and found nothing wrong.
Evrything seems ok to me.
May be you are printing an extra blank line after the last case.
Good Luck.

Re: 11220 - Decoding the message

Posted: Thu Sep 04, 2008 6:17 pm
by aeiou
To Himanshu , c d comments n change ur code...

Code: Select all


 #include<iostream>
    #include<string>
    #include<sstream>
    using namespace std;

    int main()
    {
       int T;      
       cin >> T;
       getchar(); 
       string s;
       getline(cin, s);   
       for(int i = 1; i <= T; i++)
       {   
          cout << "Case #" << i << ":" << endl;
          while(getline(cin, s))
          {

             if(s == "")   
             {
                cout << endl;          //remove this line;
                break;
             }

             istringstream sin(s);         
             string w;
             for(int j = 0; sin >> w;)
             {
               if .... 
                cout << w[j++];
             }
             cout << endl;               //add this line
          }
          if ( i < T )                            //dont print a blank line after the last test case
           cout << endl; 
       }
       return 0;
    }

Re: 11220 - Decoding the message

Posted: Sun Sep 07, 2008 6:40 pm
by naffi
I am getting RTE continuously. Can you help me?

Code: Select all

import java.util.Scanner;
import java.util.StringTokenizer;
 
class Decode
{
	public static void main(String args[])
	{
		Scanner inp = new Scanner(System.in);
		String str;
		char [] ans = new char[1000]; 
		int tc,counter,c,u;
		str = inp.nextLine();
		tc = Integer.parseInt(str);
		inp.nextLine();
		u = 1;
		while(tc > 0)
		{
			c = 0;
			while(true)
			{
				str = inp.nextLine();
				if(str.equals(""))break;						
				StringTokenizer stk = new StringTokenizer(str," ");
				counter = 0;				
				while(stk.hasMoreTokens())
				{
					String st = stk.nextToken();
					if(st.length() < counter+1)continue;
					ans[c] = st.charAt(counter);
					counter++;
					c++;
				}
				ans[c] = '$';
				c++;				
			}
			int x;
			System.out.println("Case #" + u + ":");
			for(x = 0; x < c; x++)
			{
				if(ans[x] == '$')
				{
					System.out.println("");					
				}
				else System.out.print(ans[x]);
			}
			if(tc != 1)System.out.println("");
			tc--;
			u++;
		}
	}
}

Re: 11220 - Decoding the message

Posted: Mon Sep 08, 2008 1:53 pm
by aeiou
To naffi ,

I cant find anything in ur code tat leads to rte..
usually for Java progs,the judge returns rte for WAs also..jus try increasing the length of the 'char' array to 4K or more.

Re: 11220 - Decoding the message

Posted: Mon Sep 08, 2008 1:54 pm
by aeiou
To naffi,
change the class name to "Main"...for java progs the class name should always be "Main" (in this judge)...

Re: 11220 - Decoding the message

Posted: Mon Sep 08, 2008 4:11 pm
by naffi
to Mr. Vowel

Thanks a lot, i changed class name, and got AC.

Thanks again. :D :P