I think there are some horrible things you still can do to shorten
your code.
For example:
#define x m[i+1][j
(and replace the 4 ocurrences of "m[i+1][j" to "x")
It worked on Ideone (http://www.ideone.com/) I guess it'll work on
SPOJ
Then you replace 32 chars to 18.
There must be some other horrible things like that.


On Mar 7, 11:55 am, Wladimir Tavares <[email protected]> wrote:
> This my code:
> #include <stdio.h>
> #define R(i,b) for(i=0;i<b;i++)
> #define D(i,a) for(i=a;i>=0;i--)
> #define I(d) scanf("%d",&d);
>
> main(){int t,n,i,j,m[100][100];I(t) while(t--){I(n)R(i,n)R(j,i+1)I(m[i][j])
> D(i,n-2)R(j,i+1)m[i][j] += m[i+1][j] >
> m[i+1][j+1]?m[i+1][j]:m[i+1][j+1];printf("%d\n",m[0][0]);}}
>
> 297 bytes!
>
> On Mon, Mar 7, 2011 at 11:45 AM, Wladimir Tavares 
> <[email protected]>wrote:> I create some macros like this:
>
> > #define R(i,a,b) for(i=a;i<b;i++)
> > #define D(i,a,b) for(i=a;i>=b;i--)
> > #define I(d) scanf("%d",&d);
>
> > But i don't get the accepted in this problem!
>
> > On Sun, Mar 6, 2011 at 1:55 PM, Logic King 
> > <[email protected]>wrote:
>
> >> i solved the problem on spoj based on DP i am getting the solution right
> >> but i am exceeding the following restriction
> >> "Take care about your fingers, do not use more than *256* bytes of code."
>
> >>http://www.spoj.pl/problems/SUMITR/
>
> >> My code is--
>
> >> #include<stdio.h>
> >> int arr[100][100];
> >> int main()
> >> {
> >>     int tc,n,max,i,j;
> >>     scanf("%d",&tc);
> >>     while(tc--)
> >>     {
> >>         scanf("%d",&n);
> >>         for(i=0;i<n;i++)
> >>         {
> >>             for(j=0;j<=i;j++)
> >>                 scanf("%d",&arr[i][j]);
> >>         }
> >>     for(i=n-2;i>=0;i--)
> >>     {
> >>         for(j=0;j<=i;j++)
> >>         {
>
> >>             max=(arr[i+1][j]>arr[i+1][j+1])?arr[i+1][j]:arr[i+1][j+1];
> >>         arr[i][j]=arr[i][j]+max;
> >>         }
> >>     }
> >>         printf("%d\n",arr[0][0]);
> >>     }
> >> return 0;
> >> }
>
> >> how can i reduce my my code length so that it doesn't exceed 256
> >> bytes....pl help !!
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to