Page 9 of 19
Posted: Wed Nov 28, 2007 2:26 pm
by ddddcccc30
Can anyone tell me why I get a Time limit exceeded?
Thanks.
Code: Select all
#include<iostream>
using namespace std;
int main( int argc, char * argv[] )
{ int use[10]={0,1,22,333,4444,55555,666666,7777777,88888888,999999999};
long i , j , k ,l;
long n , a , f ;
cin >> n ;
for(i=0;i<n;i++) {
cin >> a >> f;
for(j=0;j<f;j++) {
for(k=1;k<=a;k++) cout << use[k] << endl;
for(k=a-1;k>=1;k--) cout << use[k] << endl;
cout << endl;
}
}
return 0;
}
488, PE, PLES HELP
Posted: Wed Dec 19, 2007 12:41 pm
by turcse143

This my sample input output. I don't know whats the problem.
ples, help me correcting the output.
input:
2
3
2
4
3
output:
1
22
333
22
1
1
22
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
Press any key to continue
Posted: Thu Dec 20, 2007 4:16 am
by CMG
That output looks good to me. The only thing tricky about this problem is making sure not to print an empty line at for the very last triangle wave, and being able to print all of the triangle waves fast enough.
Posted: Thu Jan 17, 2008 1:21 am
by jackpigman
I'm getting lots of WAs. Can somebody help me?? Here's my code
Code: Select all
#include <stdio.h>
int main()
{
int a,b,c,d,e,f,g,i;
while(scanf("%d",&a)==1)
{
int h[a*2];
printf("\n");
for(i=0;i<=a*2-2;i=i+2)
{
scanf("%d %d",&h[i],&h[i+1]);
if(i!=a*2-2) printf("\n");
}
c=0;d=1;
for(b=1;b<=a;b++)
{
for(e=1;e<=h[d];e++)
{
for(f=1;f<=h[c];f++)
{
g=0;
while(g!=f)
{printf("%d",f);g++;}
printf("\n");
}
for(f=h[c]-1;f>=1;f--)
{
g=0;
while(g!=f)
{printf("%d",f);g++;}
printf("\n");
}
if(e!=h[d] || b!=a) printf("\n");
}
c=c+2;d=d+2;
}
}
}
Thanks for your help

!!
Posted: Thu Jan 17, 2008 6:44 am
by helloneo
You're printing an extra blank line at the first line..
PS. Remove your code after AC
Posted: Thu Jan 17, 2008 9:46 am
by jackpigman
helloneo wrote:You're printing an extra blank line at the first line..
But the question says "This line is followed by a blank line, and there is also a blank line between two consecutive inputs", so shouldn't there be a blank line after the first line

??
I did try to remove it but still got a WA...Anyway, thanks for your help

!
Posted: Tue Jan 22, 2008 6:05 am
by animenologist
Don't know where I'm doing wrong. I've tried several things and changed it around a lot, but I keep getting a wrong answer. I checked my output with every thread containing 488, but each and every time, I can't figure out what is going on.
edit: nvm I got it.
Posted: Sun Feb 10, 2008 10:17 am
by AcmNightivy
Why i got TLE..It's really strange..And i changed using scanf() and printf (),it becamed WA..And i want to know what is blue flag,and what is the meaning of so called multiple input.It isn't like the input about this problem?Thanks in advance~
Code: Select all
#include <iostream.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"};
cin>>caseNum;
for (i = 0; i < caseNum; i++)
{
cin>>a>>f;
for (j = 0; j < f; j++)
{
for (k = 1; k <= a; k++)
{
cout<<num[k]<<endl;
}
k = k - 2;
for (; k >= 1; k--)
{
cout<<num[k]<<endl;
}
cout<<endl;
}
}
return 0;
}
why is my program TLE???
Posted: Tue Feb 19, 2008 9:32 pm
by fR0D
Posted: Tue Feb 19, 2008 9:43 pm
by mf
cout and cin are very slow.
Try to use putchar/printf/scanf instead.
Or as an option, call std::ios::sync_with_stdio(false); at the start of your program. This should make it a little faster.
Posted: Fri Feb 22, 2008 3:01 pm
by fR0D
thnx vry much it helped nd i got AC.
Crazzzzzzzzzzzzy WA...488
Posted: Sun Feb 24, 2008 8:00 am
by Obaida
why this will get WA.....
Code: Select all
#include <stdio.h>
int main()
{
int a,b,i,j,k,n,s;
while(scanf("%d",&n)==1)
{
printf("\n");
s=0;
while(s!=n)
{
scanf("%d %d",&a,&b);
printf("\n");
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
for(i=a-2;i>=0;i--)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
printf("\n");
}
s++;
}
}
return 0;
}
some one please help me............. please....
Stupid problem........
Posted: Tue Feb 26, 2008 8:23 am
by Obaida
Thank you......488.... it give me at least 20 or more wA.... some one please help me..........please.........
Re: Stupid problem........
Posted: Tue Feb 26, 2008 8:59 am
by helloneo
Obaida wrote:Thank you......488.... it give me at least 20 or more wA.... some one please help me..........please.........
You are printing an extra '\n' at the first line of the output..
PS. Remove you code after AC..

stupid......problem.
Posted: Tue Feb 26, 2008 11:49 am
by Obaida
Now look at my output.... I thik thats good.... but still WA
Code: Select all
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