Page 1 of 1

10333 - The Tower of ASCII

Posted: Sun Jul 14, 2002 3:08 pm
I try to solve this problem on contest but get Time Limit. Then I change my program in proper way but get Wrong Answer. After contest I send the program and it get Accepted P.E. runnig 1.060 seconds. I just wonder how to get Accepted with time less that 0.100 seconds using Pascal. And I think that it is impossible; but then why ProblemSetter hadn't thougth about this?

Posted: Fri Oct 25, 2002 2:16 pm
I get WA when submit the following code , why , Can somobody tell me ?

are there any line break I don't know ?
that things do things with this problems?

///////////////////////////////////////////////////////////

#include<iostream.h>
void main()
{
int n , sum , a[500],i,k,tm=0, j,m,first,first1,g,wide,wid2;
while(!cin.eof())
{
sum = 0 ;
i = 0 ;
j = 0 ;
cin>>n ;
cout<<"Tower : #"<<++tm<<endl;
do{
sum += ++i ;
a[i-1] = i ;
}while(sum<n) ;
j = i - 1 ;
if(sum > n)
{
a[i-1] = n - sum + i ;

if(a[i-1]<a[i-2])
{
a[i-2] += a[i-1] ;
j = i - 2 ;
}

if(a[i-1] == a[i-2] )
{
a[i-2] *= 2 ;
j = i-2 ;
}
}
//cout<<j<<" "<<i<<" "<<a[i-2]<<endl ;
///////////////////////////////////////
for(m = 0; m < j; m++)
{
first = 2*(j - m) ;
first1 = first ;
wide = 4*m ;
wid2 = wide+4 ;
while(first--)
cout<<' ' ;
cout<<"#**" ;
while(wide--)
cout<<'.' ;
cout<<"**#" ;
cout<<endl ;
for(g = 0 ; g < a[m]-1; g++)
{
for(k=0;k<first1;k++)
cout<<' ' ;
cout<<'#' ;
for(k= wid2;k>0;k--)
cout<<'.';
cout<<'#'<<endl ;
}
}
///////////////////////////////////////
wide =4*(j) ;
wid2 = wide+2 ;
cout<<"#**" ;
while(wide--)
cout<<'.' ;
cout<<'#' ;
cout<<endl ;
for( g = 0 ; g < a[j]-1; g++)
{
cout<<'#' ;
for(k= wid2;k>0;k--)
cout<<'.';
cout<<'#'<<endl ;
}
cout<<endl;
}
}

10333

Posted: Sun Nov 10, 2002 1:35 pm
My code get the right graphic like the example
but it get WA
I can examine it's why

can anybody tell me why?
my code is following :

#include<iostream.h>
void main()
{
int n , sum , a[500],i,k,tm=0, j,m,first,first1,g,wide,wid2;
while(!cin.eof())
{
sum = 0 ;
i = 0 ;
j = 0 ;
cin>>n ;
cout<<"Tower : #"<<++tm<<endl;
do{
sum += ++i ;
a[i-1] = i ;
}while(sum<n) ;
j = i - 1 ;
if(sum > n)
{
a[i-1] = n - sum + i ;

if(a[i-1]<a[i-2])
{
a[i-2] += a[i-1] ;
j = i - 2 ;
}

if(a[i-1] == a[i-2] )
{
a[i-2] *= 2 ;
j = i-2 ;
}
}
//cout<<j<<" "<<i<<" "<<a[i-2]<<endl ;
///////////////////////////////////////
for(m = 0; m < j; m++)
{
first = 2*(j - m) ;
first1 = first ;
wide = 4*m ;
wid2 = wide+4 ;
while(first--)
cout<<' ' ;
cout<<"#**" ;
while(wide--)
cout<<'.' ;
cout<<"**#" ;
cout<<endl ;
for(g = 0 ; g < a[m]-1; g++)
{
for(k=0;k<first1;k++)
cout<<' ' ;
cout<<'#' ;
for(k= wid2;k>0;k--)
cout<<'.';
cout<<'#'<<endl ;
}
}
///////////////////////////////////////
wide =4*(j) ;
wid2 = wide+2 ;
cout<<"#**" ;
while(wide--)
cout<<'.' ;
cout<<'#' ;
cout<<endl ;
for( g = 0 ; g < a[j]-1; g++)
{
cout<<'#' ;
for(k= wid2;k>0;k--)
cout<<'.';
cout<<'#'<<endl ;
}
cout<<endl;
}
}

Posted: Tue Feb 25, 2003 12:07 am
post some input

10333 Wrong Anwers, But The Output is Correct

Posted: Thu Jun 12, 2003 12:25 pm

Code: Select all

``````[c]
#include<stdio.h>

void main() {
int n , sum , a[500],i,k,tm=1, j,m,first,first1,g,wide,wid2;

#ifndef ONLINE_JUDGE
freopen("10333.in", "r", stdin);
freopen("10333.out", "w", stdout);
#endif
while(scanf("%d",&n)==1)
{
sum = 0 ;
i = 0 ;
j = 0 ;
printf("Tower : #%d\n",tm);
tm++;
do
{
sum += ++i ;
a[i-1] = i ;
} while(sum<n) ;

j = i - 1 ;

if(sum > n) {
a[i-1] = n - sum + i ;

if(a[i-1]<a[i-2]) {
a[i-2] += a[i-1] ;
j = i - 2 ;
}

if(a[i-1] == a[i-2] ) {
a[i-2] *= 2 ;
j = i-2 ;
}
}

for(m = 0; m < j; m++) {
first = 2*(j - m) ;
first1 = first ;
wide = 4*m ;
wid2 = wide+4 ;

while(first--)	printf(" ");
printf("#**");
while(wide--)  printf(".");
printf("**#\n");
for(g = 0 ; g < a[m]-1; g++) {
for(k=0;k<first1;k++) printf(" ");
printf("#");
for(k= wid2;k>0;k--) printf(".");
printf("#\n");
}
}

wide =4*(j) ;
wid2 = wide+2 ;
printf("#**");

while(wide--) printf(".");
printf("#\n");

for( g = 0 ; g < a[j]-1; g++) {
printf("#");
for(k= wid2;k>0;k--) printf(".");
printf("#\n");
}
printf("\n");
fflush(stdin);
}
}

[/c]``````

Posted: Thu Sep 25, 2003 12:46 am
Can someone post something?

Re: 10333 Wrong Anwers, But The Output is Correct

Posted: Thu Feb 12, 2004 5:03 pm
yayas wrote:

Code: Select all

``````printf("Tower : #%d\n",tm);
``````
That is OK with the Output part of the problem, but their test output simply writes:

Code: Select all

``````Tower #n
``````
I have got AC after removing colon and space.

to yayas

Posted: Tue Sep 20, 2005 9:25 am
Change your location of feof. The output of your program is CORRECT. I checked your program and it was exactly same. I got AC.

Thus, change your location of feof. (Don't use scanf to check that. )

The input data ends with tricky.

Re: 10333 - The Tower of ASCII

Posted: Sun Apr 03, 2011 3:03 am
Input:

Code: Select all

``````100
500
``````

Code: Select all

``````Tower #1
#****#
#**....**#
#........#
#**........**#
#............#
#............#
#**............**#
#................#
#................#
#................#
#**................**#
#....................#
#....................#
#....................#
#....................#
#**....................**#
#........................#
#........................#
#........................#
#........................#
#........................#
#**........................**#
#............................#
#............................#
#............................#
#............................#
#............................#
#............................#
#**............................**#
#................................#
#................................#
#................................#
#................................#
#................................#
#................................#
#................................#
#**................................**#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#**....................................**#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#**........................................**#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#**............................................**#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#**................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#
#..................................................#

Tower #2
#****#
#**....**#
#........#
#**........**#
#............#
#............#
#**............**#
#................#
#................#
#................#
#**................**#
#....................#
#....................#
#....................#
#....................#
#**....................**#
#........................#
#........................#
#........................#
#........................#
#........................#
#**........................**#
#............................#
#............................#
#............................#
#............................#
#............................#
#............................#
#**............................**#
#................................#
#................................#
#................................#
#................................#
#................................#
#................................#
#................................#
#**................................**#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#....................................#
#**....................................**#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#........................................#
#**........................................**#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#............................................#
#**............................................**#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#................................................#
#**................................................**#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#....................................................#
#**....................................................**#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#........................................................#
#**........................................................**#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#............................................................#
#**............................................................**#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#................................................................#
#**................................................................**#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#....................................................................#
#**....................................................................**#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#........................................................................#
#**........................................................................**#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#............................................................................#
#**............................................................................**#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#................................................................................#
#**................................................................................**#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#....................................................................................#
#**....................................................................................**#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#........................................................................................#
#**........................................................................................**#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#............................................................................................#
#**............................................................................................**#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#................................................................................................#
#**................................................................................................**#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#....................................................................................................#
#**....................................................................................................**#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#........................................................................................................#
#**........................................................................................................**#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#............................................................................................................#
#**............................................................................................................**#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#................................................................................................................#
#**................................................................................................................**#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#....................................................................................................................#
#**....................................................................................................................**#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#........................................................................................................................#
#**........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#

``````