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
helloneo
Guru
Posts: 516 Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Post
by helloneo » Tue Feb 26, 2008 12:09 pm
Obaida wrote: Now look at my output.... I thik thats good.... but still WA
Actually your code prints output this way..
\n
2\n
\n
3\n
2\n
1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1\n
\n
3\n
2\n
1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1\n
Obaida
A great helper
Posts: 380 Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.
Post
by Obaida » Tue Feb 26, 2008 12:36 pm
I think I can't read you.... still WA....
look at my code...... what should be edited...
Last edited by
Obaida on Sat Mar 01, 2008 10:58 am, edited 1 time in total.
try_try_try_try_&&&
_try@try.com
This may be the address of success.
AcmNightivy
New poster
Posts: 36 Joined: Tue Dec 04, 2007 10:20 am
Post
by AcmNightivy » Thu Feb 28, 2008 4:18 pm
I change in using stdio..but still WA..Help!!Thanks!!
Code: Select all
#include <stdio.h>
int main ()
{
int i, j, k;
int caseNum;
int a, f;
char num[10][10] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"};
scanf ("%d", &caseNum);
for (i = 0; i < caseNum; i++)
{
scanf ("%d%d", &a, &f);
for (j = 0; j < f; j++)
{
for (k = 1; k <= a; k++)
{
printf ("%s\n", num[k]);
}
k = k - 2;
for (; k >= 1; k--)
{
printf ("%s\n", num[k]);
}
//if (i != caseNum - 1)
printf ("\n");
}
}
return 0;
}
Obaida
A great helper
Posts: 380 Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.
Post
by Obaida » Sat Mar 01, 2008 6:07 am
Some one please could tell me from my above code... that where is the extra \n in my program.... I couldn't find it.... But still I had to belive because I am getting WA in this problem......
try_try_try_try_&&&
_try@try.com
This may be the address of success.
CSEDU_1323
New poster
Posts: 10 Joined: Mon Feb 25, 2008 8:22 pm
Location: Dhaka, Bangladesh.
Post
by CSEDU_1323 » Sat Mar 01, 2008 9:52 am
hi,
Obaida, helloneo trace out ur error u print a extra new line in d front
use if(l>= 1 &&l<n)
instead if(l>= 0 &&l<n)
will do ur work
&&
u don't need 2 take test case more than once
HOPE THIS HELPS
--- B HAPPY & KEEP SMILING ------
Obaida
A great helper
Posts: 380 Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.
Post
by Obaida » Sat Mar 01, 2008 12:12 pm
Thank You very much.....! I got Accepted..... But in the instruction of the program it is mentoned that we had to print a blank line after test case....
But afterall thank you.... very much....
try_try_try_try_&&&
_try@try.com
This may be the address of success.
pwilt
New poster
Posts: 2 Joined: Wed Apr 09, 2008 6:59 pm
Post
by pwilt » Thu Apr 17, 2008 3:03 am
I seem to be getting the answer correct (tried to follow the formatting in the other posts to the letter) but I'm still getting WA from the judge. Can anybody point out something that I've missed?
Code: Select all
#include <iostream>
#include <string>
using namespace std;
int main(){
int tc;
cin >> tc;
string nums[9] = {"1","22","333","4444","55555","666666","7777777","88888888","999999999"};
short amp, freq, j;
for (int i = 1; i <= tc; i++){
cin >> amp;
cin >> freq;
for (short k = 1; k <= freq; k++){
for (j = 0; j < amp; j++){
cout << nums[j] << endl;
}
for (j -= 2; j >= 0; j--){
cout << nums[j] << endl;
}
if (k < freq){
cout << endl;
}
}
if (i < tc){
cout << endl;
}
}
}
pwilt
New poster
Posts: 2 Joined: Wed Apr 09, 2008 6:59 pm
Post
by pwilt » Sat Apr 19, 2008 3:54 am
Bump?
t_sergiu
New poster
Posts: 12 Joined: Sun Mar 02, 2008 6:18 am
Post
by t_sergiu » Sun Apr 20, 2008 4:57 pm
I am getting a TLE on this problem as well. I would think it wouldn't take any time at all to run this. Can anybody offer some suggestions?
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Sun Apr 20, 2008 5:47 pm
No idea. Are you sure you are taking input correctly? You can check your solution by sending a solution which just takes the input.
t_sergiu
New poster
Posts: 12 Joined: Sun Mar 02, 2008 6:18 am
Post
by t_sergiu » Sun Apr 20, 2008 6:34 pm
Fixed. I was using cin and cout. Switched it to use printf and scanf, and did it in 1/10 of a second.
Obaida
A great helper
Posts: 380 Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.
Post
by Obaida » Tue Apr 22, 2008 9:45 am
But this is Actually WA...!
Not PE...
In "int main()" type you should use "return 0;"
But you didn't do it.
try_try_try_try_&&&
_try@try.com
This may be the address of success.
hahahaken
New poster
Posts: 26 Joined: Tue May 27, 2008 10:42 am
Post
by hahahaken » Tue May 27, 2008 12:27 pm
My code got time limit exceeded.
How to reduce the time? Coz I don't know the maximum number of input.
Last edited by
hahahaken on Fri May 30, 2008 10:33 am, edited 1 time in total.
Obaida
A great helper
Posts: 380 Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.
Post
by Obaida » Wed May 28, 2008 8:34 am
If you use array then you can solve the problem by pre-initialization, it can be like:
Code: Select all
int use[10]={0,1,22,333,4444,55555,666666,7777777,88888888,999999999};
then just print the current value of use[i] and make the wave. It will be more faster and efficient.
else you can do it without any use of array then it can be a little slow.
>>may this help you.
try_try_try_try_&&&
_try@try.com
This may be the address of success.
hahahaken
New poster
Posts: 26 Joined: Tue May 27, 2008 10:42 am
Post
by hahahaken » Wed May 28, 2008 9:54 am
Obaida wrote: If you use array then you can solve the problem by pre-initialization, it can be like:
Code: Select all
int use[10]={0,1,22,333,4444,55555,666666,7777777,88888888,999999999};
then just print the current value of use[i] and make the wave. It will be more faster and efficient.
else you can do it without any use of array then it can be a little slow.
>>may this help you.
Still TLE
Here's the updated version:
Last edited by
hahahaken on Fri May 30, 2008 10:34 am, edited 1 time in total.