196 - Spreadsheet

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

suneast
New poster
Posts: 49
Joined: Sun Jan 17, 2010 6:25 am
Location: FZU
Contact:

Re: What a strange problem: 196!

Post by suneast »

yeah , I got AC now...

here is a small test case for the ont who getting WA :D

Code: Select all

1
1 8
1	=C1+H1	=D1+G1	=F1+E1	=F1	=G1	=H1	8
output from my Ac code

Code: Select all

1 32 24 16 8 8 8 8
hope I am help to you all... :wink:

bryan12
New poster
Posts: 1
Joined: Sun Sep 19, 2010 6:56 pm

Re: Problem 196 (spreadsheet)

Post by bryan12 »

Hi guys I'm new solving acm problems and I can't get AC with this problem, may be I forget some tricky case :(

So far my program can handle with this cases:

Input

Code: Select all

4
8 1
1 =C1+H1 =D1+G1 =F1+E1 =F1 =G1 =H1 8
30 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 =AA2
=AA1+B2+AC2 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000
5 5
5 7 11 22 -1
=B1+B2+B3 0 5 16 -2
8 =C1+D2+E5 14 13 =A5+E1
5 10 20 100 -10
=D3+C4 15 13 =C1 200 
2 2
=B1+B2 7
=B2+A2 6

Output

Code: Select all

1 32 24 16 8 8 8 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2700
3127 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000
5 7 11 22 -1
234 0 5 16 -2
8 227 14 13 32
5 10 20 100 -10
33 15 13 11 200
13 7
6 6

I need some help, may be the error is in the output or I forget a requirement but I can't find it

Thanks
bRyAn

ZebraRabbit
New poster
Posts: 1
Joined: Tue Aug 14, 2012 4:25 pm
Location: BUCT
Contact:

Re: 196 spreadsheet WA??

Post by ZebraRabbit »

:)Although I tried all of these test data in this page and I got the correct answer,I still WA.My code got AC in the POJ,but I can't make it in UVA. I feel so disappointed.And then when I want to give up,I found a ridiculous mistake in my code.Maybe your mistake is the same as mine.
Can you transform the formula correctly? Like =AAA123+EW23 or =A10+B12.
All of test data in this page don't contain the row number which is bigger than 10 !
There is nothing better than to see a smiling face of a good friend.

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Re: What a strange problem: 196!

Post by Darko »

Here is one case that I originally failed, maybe it can help others:

Code: Select all

1
2 2
10 =A1+A1
10 10

Code: Select all

10 20
10 10

oesteves
New poster
Posts: 4
Joined: Wed Mar 05, 2014 8:20 pm

196 - Spreadsheet - RE

Post by oesteves »

I'm working on this problem for 2 weeks. I finished my solution in one morning but, since then, I'm trying to get AC with no success. Whatever I try, I get a Runtime error. It compiles OK using mingw and it passed all the examples I tried. Here is my code:

Code: Select all


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>


/*
 * DEFINES
 */
#define MAXN        1001
#define FALSE       0
#define TRUE        1
#define INF         2147483647

#define sFinalMatrix(a,b)     resultMatrix[a+18279*b]

#define bool        char

/*
* GLOBAL VARIABLES
*/
typedef struct
{
    int value;
    char resolved;
    char *p;
} cCell;

int iNumCols = 0;
int iNumRows = 0;

//static cCell sFinalMatrix[MAXN][18280];
cCell   resultMatrix[MAXN*18280];


long iFnSumCell( char *str, int x, int y )
{
long sum = 0;
int i = 1;
int len = 0;
int rowN = 0;
int colN = 0;
long temp = 0;

    if(sFinalMatrix(x,y).p == NULL)
    {
        /* It is a pure number, return "column"*/
        return x;
    }

    len = strlen( str );
    if (len < MAXN)
    {
        str[len] = '+';
        str[len + 1] = '\0';
    }
    else len = MAXN;

    /* Check boundaries */
    if(x>MAXN) x = MAXN;

    if(y>18278) y = 18278;

    while ((str[i]) && (i<18278))
    {
        if( isalpha(str[i]) )
        {
            if(islower(str[i])) str[i] = toupper(str[i]);
            colN = colN * 26 + ( str[i] - 'A' + 1 );
        }
        else
            if ( isdigit(str[i]) )
            rowN += rowN * 10 + ( str[i] - '0' );
        else if ( rowN == x && colN == y )
        {
            rowN = 0;
            colN = 0;
            return -INF;
        }
        else if ( sFinalMatrix(rowN,colN).resolved == FALSE )
        {
            /* Checking Matrix boundaries */
            if(rowN > MAXN) rowN = MAXN-1;
            if(colN > 18278) colN = 18277;

            temp = iFnSumCell( (char *)sFinalMatrix(rowN,colN).p, rowN, colN );
            if ( temp == -INF ) return -INF;
            sum += temp;
            sFinalMatrix(rowN,colN).value = temp;
            sFinalMatrix(rowN,colN).resolved = TRUE;
            free( sFinalMatrix(rowN,colN).p );
            rowN = 0;
            colN = 0;
        }
        else
        {
            sum += sFinalMatrix(rowN,colN).value;
            free( sFinalMatrix(rowN,colN).p );
            rowN = 0;
            colN = 0;
        }
        i++;
    }
    return sum;
}

bool FnCalcMatrix(void)
{
    int r,c;

    for ( r = 1; r <= iNumRows; r++ )
        for ( c = 1; c <= iNumCols; c++ )
            if ( sFinalMatrix(r,c).resolved == FALSE )
            {
                long temp = iFnSumCell( sFinalMatrix(r,c).p, r, c );
                if ( temp == -INF ) return FALSE;
                else
                {
                    sFinalMatrix(r,c).value = temp;
                    sFinalMatrix(r,c).resolved = TRUE;
                    free(sFinalMatrix(r,c).p);
                }
            }
    return TRUE;
}

int main(void)
{
    unsigned int uiNumSheets = 0;
    unsigned int uiSheetsIx = 0;

    /* Enter number of sheets */
    scanf("%d", &uiNumSheets);

    for(uiSheetsIx = 0; uiSheetsIx < uiNumSheets; uiSheetsIx++)
    {
        int iColsIx = 0;
        int iRowsIx = 0;

        /* Enter number of rows and columns*/
        scanf("%d%d", &iNumCols, &iNumRows);

        if(iNumCols > 18278) return 0;
        if(iNumRows > 1000) return 0;

        /* Rows Input */
        for(iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx++)
        {
            /* Cols Input */
            for(iColsIx = 1; iColsIx <= iNumCols; iColsIx++)
            {
                /* Check if it is a value or a formula */
                if ( scanf("%d",&sFinalMatrix(iRowsIx,iColsIx).value) == 0 )
                {
                    int inputLen = 0;
                    sFinalMatrix(iRowsIx,iColsIx).p = (char *)malloc( 2048 * sizeof(char) );

                    if ( NULL == sFinalMatrix(iRowsIx,iColsIx).p) return 0;

                    inputLen = scanf("%1024s", sFinalMatrix(iRowsIx,iColsIx).p );
                    if (inputLen > MAXN) return 0;
                    if(sFinalMatrix(iRowsIx,iColsIx).p[0] == '=')
                    {
                        sFinalMatrix(iRowsIx,iColsIx).resolved = FALSE;
                        sFinalMatrix(iRowsIx,iColsIx).value = 0;
                    }
                    else
                    {
                        /* Invalid formula! */
                        sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
                        sFinalMatrix(iRowsIx,iColsIx).value = 0;
                        sFinalMatrix(iRowsIx,iColsIx).p = NULL;
                    }
                }
                else
                {
                    sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
                    sFinalMatrix(iRowsIx,iColsIx).p = NULL;
                }
            }
        }

        FnCalcMatrix();

        /* Show Final Matrix - Results */
        for ( iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx ++ )
        {
            for ( iColsIx = 1; iColsIx <= iNumCols; iColsIx++ )
            {
                if (iColsIx !=1 ) printf(" ");
                printf( "%d", sFinalMatrix(iRowsIx,iColsIx).value );
            }
            printf("\n");
        }
    }

    return 0;
}
By commenting some lines and submitting the code, I discovered that the error is related to the recursive function call in line 86 ("temp = iFnSumCell( (char *)sFinalMatrix(rowN,colN).p, rowN, colN );". Could anyone please point me where is my mistake?

Thank you!

Regards,

Omar.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 196 - Spreadsheet - RE

Post by brianfry713 »

Here is your code with indentation and some debug print statements added.

Code: Select all

#define DEBUG 1

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>


/*
* DEFINES
*/
#define MAXN 1001
#define FALSE 0
#define TRUE 1
#define INF 2147483647

#define sFinalMatrix(a,b) resultMatrix[a+18279*b]

#define bool char

/*
* GLOBAL VARIABLES
*/
typedef struct
{
  int value;
  char resolved;
  char *p;
} cCell;

int iNumCols = 0;
int iNumRows = 0;

//static cCell sFinalMatrix[MAXN][18280];
cCell resultMatrix[MAXN*18280];


long iFnSumCell( char *str, int x, int y )
{
  long sum = 0;
  int i = 1;
  int len = 0;
  int rowN = 0;
  int colN = 0;
  long temp = 0;
  
  if(sFinalMatrix(x,y).p == NULL)
    {
      /* It is a pure number, return "column"*/
      return x;
    }
  len = strlen( str );
  if (len < MAXN)
    {
      str[len] = '+';
      str[len + 1] = '\0';
    }
  else len = MAXN;
  
  /* Check boundaries */
  if(x>MAXN) x = MAXN;
  
  if(y>18278) y = 18278;
  
  while ((str[i]) && (i<18278))
    {
      if( isalpha(str[i]) )
	{
	  if(islower(str[i])) str[i] = toupper(str[i]);
	  colN = colN * 26 + ( str[i] - 'A' + 1 );
	}
      else
	if ( isdigit(str[i]) )
	  rowN += rowN * 10 + ( str[i] - '0' );
	else if ( rowN == x && colN == y )
	  {
	    rowN = 0;
	    colN = 0;
	    return -INF;
	  }
	else if ( sFinalMatrix(rowN,colN).resolved == FALSE )
	  {
	    /* Checking Matrix boundaries */
	    if(rowN > MAXN) rowN = MAXN-1;
	    if(colN > 18278) colN = 18277;
	    
	    temp = iFnSumCell( (char *)sFinalMatrix(rowN,colN).p, rowN, colN );
	    if ( temp == -INF ) return -INF;
	    sum += temp;
	    sFinalMatrix(rowN,colN).value = temp;
	    sFinalMatrix(rowN,colN).resolved = TRUE;
	    if(DEBUG)
	      printf("test free1 row %d, col %d, string %s, mem %d\n", rowN, colN, sFinalMatrix(rowN,colN).p, sFinalMatrix(rowN,colN).p);
	    free( sFinalMatrix(rowN,colN).p );
	    if(DEBUG)
	      printf("test free1 done\n");
	    rowN = 0;
	    colN = 0;
	  }
	else
	  {
	    sum += sFinalMatrix(rowN,colN).value;
	    if(DEBUG)
	      printf("test free2 row %d, col %d, string %s, mem %d\n", rowN, colN, sFinalMatrix(rowN,colN).p, sFinalMatrix(rowN,colN).p);
	    free( sFinalMatrix(rowN,colN).p );
	    if(DEBUG)
	      printf("test free2 done\n");
	    rowN = 0;
	    colN = 0;
	  }
      i++;
    }
  return sum;
}

bool FnCalcMatrix(void)
{
  int r,c;
  
  for ( r = 1; r <= iNumRows; r++ )
    for ( c = 1; c <= iNumCols; c++ )
      if ( sFinalMatrix(r,c).resolved == FALSE )
	{
	  long temp = iFnSumCell( sFinalMatrix(r,c).p, r, c );
	  if ( temp == -INF ) return FALSE;
	  else
	    {
	      sFinalMatrix(r,c).value = temp;
	      sFinalMatrix(r,c).resolved = TRUE;
	      free(sFinalMatrix(r,c).p);
	    }
	}
  return TRUE;
}

int main(void)
{
  unsigned int uiNumSheets = 0;
  unsigned int uiSheetsIx = 0;
  
  /* Enter number of sheets */
  scanf("%d", &uiNumSheets);
  
  for(uiSheetsIx = 0; uiSheetsIx < uiNumSheets; uiSheetsIx++)
    {
      int iColsIx = 0;
      int iRowsIx = 0;
      
      /* Enter number of rows and columns*/
      scanf("%d%d", &iNumCols, &iNumRows);
      
      if(iNumCols > 18278) return 0;
      if(iNumRows > 1000) return 0;
      
      /* Rows Input */
      for(iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx++)
	{
	  /* Cols Input */
	  for(iColsIx = 1; iColsIx <= iNumCols; iColsIx++)
	    {
	      /* Check if it is a value or a formula */
	      if ( scanf("%d",&sFinalMatrix(iRowsIx,iColsIx).value) == 0 )
		{
		  int inputLen = 0;
		  sFinalMatrix(iRowsIx,iColsIx).p = (char *)malloc( 2048 * sizeof(char) );
		  
		  if ( NULL == sFinalMatrix(iRowsIx,iColsIx).p) return 0;
		  
		  inputLen = scanf("%1024s", sFinalMatrix(iRowsIx,iColsIx).p );
		  if(DEBUG)
		    printf("malloc row %d, col %d, string %s, mem %d\n", iRowsIx, iColsIx, sFinalMatrix(iRowsIx,iColsIx).p, sFinalMatrix(iRowsIx,iColsIx).p);
		  if (inputLen > MAXN) return 0;
		  if(sFinalMatrix(iRowsIx,iColsIx).p[0] == '=')
		    {
		      sFinalMatrix(iRowsIx,iColsIx).resolved = FALSE;
		      sFinalMatrix(iRowsIx,iColsIx).value = 0;
		    }
		  else
		    {
		      /* Invalid formula! */
		      sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
		      sFinalMatrix(iRowsIx,iColsIx).value = 0;
		      sFinalMatrix(iRowsIx,iColsIx).p = NULL;
		    }
		}
	      else
		{
		  sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
		  sFinalMatrix(iRowsIx,iColsIx).p = NULL;
		}
	    }
	}
      
      FnCalcMatrix();

      /* Show Final Matrix - Results */
      for ( iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx ++ )
	{
	  for ( iColsIx = 1; iColsIx <= iNumCols; iColsIx++ )
	    {
	      if (iColsIx !=1 ) printf(" ");
	      printf( "%d", sFinalMatrix(iRowsIx,iColsIx).value );
	    }
	  printf("\n");
	}
    }
  
  return 0;
}
Here is the output running this on my machine with the sample input:

Code: Select all

malloc row 1, col 4, string =A1+B1+C1, mem 298024976
malloc row 2, col 4, string =A2+B2+C2, mem 298027040
malloc row 3, col 1, string =A1+A2, mem 298029104
malloc row 3, col 2, string =B1+B2, mem 298031168
malloc row 3, col 3, string =C1+C2, mem 298033232
malloc row 3, col 4, string =D1+D2, mem 298035296
test free2 row 1, col 1, string (null), mem 0
test free2 done
test free2 row 1, col 2, string (null), mem 0
test free2 done
test free2 row 1, col 3, string (null), mem 0
test free2 done
test free2 row 2, col 1, string (null), mem 0
test free2 done
test free2 row 2, col 2, string (null), mem 0
test free2 done
test free2 row 2, col 3, string (null), mem 0
test free2 done
test free2 row 1, col 1, string (null), mem 0
test free2 done
test free2 row 2, col 1, string (null), mem 0
test free2 done
test free2 row 1, col 2, string (null), mem 0
test free2 done
test free2 row 2, col 2, string (null), mem 0
test free2 done
test free2 row 1, col 3, string (null), mem 0
test free2 done
test free2 row 2, col 3, string (null), mem 0
test free2 done
test free2 row 1, col 4, string ?6??*, mem 298024976
*** glibc detected *** double free or corruption (!prev): 0x0000000011c38010 ***Abort
Check input and AC output for thousands of problems on uDebug!

oesteves
New poster
Posts: 4
Joined: Wed Mar 05, 2014 8:20 pm

Re: 196 - Spreadsheet - RE

Post by oesteves »

Thank you very much, brianfry173!

I'm running this in a Windows machine and i don't receive that output "*** glibc detected *** double free or corruption (!prev): 0x0000000011c38010 ***Abort". However, with your debugs I see that the second free ("test free2 row 1, col 2, string (null), mem 0", for example) is redundant. It isn't needed. So, i removed that part. But, I'm still getting Runtime Error... :-(

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 196 - Spreadsheet - RE

Post by brianfry713 »

Input:

Code: Select all

5
4 1
73 77 =B1+B1+B1 =B1+C1+B1
5 3
18 95 5 =A1 53
44 =C1+B3+C3 =D3+C3 11 40
79 =E3 =A1+D1+A1 70 62
10 10
=J2+E3+J1 =E1 80 =J6 77 =E5 73 =I9+F1+D7 =C9+I10+D5 =J10
31 =I6 =F8 =D1+F7 =F3+A3 58 73 66 =B2+G3 =C5+B4
0 =G8+A3+J10 65 48 94 18 =A3+D6+E10 =C9 40 98
=G1+A10 =F2+C1+F2 =A3+F2+F8 30 84 70 =G10 17 =J6+C4+E6 =G8+E6
44 81 43 =I9+B8 19 =H4+I9 82 91 70 79
=F7+A2+I9 =C3+I10+J10 =J8 83 3 =F7+D3+G4 =G10+D10+F7 =J2+C9+G1 21 =C1+J5
=D5 26 =G10+D5+I9 35 31 =D8+I9+H4 79 61 96 =B3+A6+D8
43 =I9 30 77 9 =D8+H4 92 84 =J1+A1 32
95 46 =I9 =G7 =F2+G6+B1 =G1 20 =G1+F7+D8 10 14
9 71 =D8+C9 72 =C9+C1 =I3+D5+E6 3 63 =C5+B8+F2 92
8 10
38 =E7+C9+F10 66 68 =A1+A1+C7 91 =H5+H1+A1 =G10+C9
1 5 =B2+B5+A10 =F6+A9+B9 42 =A1+A4+B8 82 =B2+C7+G8
29 70 95 =B2+C3 45 66 0 =H4+H5+F4
=G7+G8 =A7 =H6+E7+A4 54 =E2+D10+D6 4 =G10+A7 67
=B4 15 =G2+A7+F10 20 78 52 =E8+H9 0
=H4+E1 87 8 63 45 =B5+C9 =C10+B7+H2 =A7
=C9+C9+C9 89 =C9+F5+C5 45 67 42 =B5 =C5+H9
=C9+A7 =C9+C10 0 =G6+D1+D6 =B2 75 =B2+C7 =C9+C9+C9
=F6+A2+H8 65 76 =H1 =D10+E6 68 70 33
40 =G4 70 97 55 76 47 =H6
10 10
51 =A5+C1 =D9+G1+H4 =I1+G8+H7 59 =J1+B1+E4 =E6+J3+E6 98 =A1+H4+I9 4
96 34 =B3+H6 59 =A5+F5+A1 =D6+A1+E8 =F5 =E7 =I6 =F2+I1
=H2 38 =D10 28 =F5 90 86 =J3+C7+E8 =E8+D8 89
91 22 =E2 =E7+B5 =C4+C6 56 =J1 =D8+A1 83 71
36 =J8+J9+G10 84 12 32 =F9+A3 60 =J3 =H9 27
=I9+F2 =E8 27 97 4 79 =B1+E7 =G1+H2+E10 =B1+E2+E10 =A5+F3+D9
62 15 =I3+G1 =H8+F4 13 41 82 =E10+A3 72 =J3
99 =H2 =I1 83 46 =D5 =C6 85 58 14
=H2+F9 =E1 81 =H8+H6 72 99 42 =F5+H10 =J3 =H8
=A8 =C3 =E1 43 =H2+D8+E7 =D2+E7+J7 =H4+I9+E10 69 =H8 =H9+H10+C5
AC output:

Code: Select all

73 77 231 385
18 95 5 18 53
44 121 124 11 40
79 62 54 70 62
425 77 80 159 77 19 73 64 141 92
31 21 94 263 18 58 73 66 194 239
0 184 65 48 94 18 173 10 40 98
82 196 152 30 84 70 3 17 314 95
44 81 43 20 19 27 82 91 70 79
145 268 32 83 3 155 179 322 21 159
20 26 33 35 31 104 79 61 96 406
43 10 30 77 9 94 92 84 517 32
95 46 10 79 314 73 20 254 10 14
9 71 87 72 90 63 3 63 111 92
38 219 66 68 590 91 161 123
1 5 60 476 42 718 82 1038
29 70 95 100 45 66 0 71
534 228 829 54 202 4 275 67
228 15 386 20 78 52 38 0
657 87 8 63 45 91 1197 228
228 89 514 45 67 42 15 419
304 146 0 1328 5 75 519 228
320 65 76 123 142 68 70 33
40 275 70 97 55 76 47 228
51 571 535 423 59 801 97 98 274 4
96 34 257 59 199 194 112 13 879 468
13 38 43 28 112 90 86 361 129 89
91 22 199 444 226 56 4 134 83 71
36 431 84 12 32 112 60 89 181 27
283 46 27 97 4 79 584 219 879 430
62 15 226 141 13 41 82 122 72 89
99 13 274 83 46 12 27 85 58 14
112 59 81 304 72 99 42 181 89 85
99 43 59 43 109 161 332 69 85 334
Check input and AC output for thousands of problems on uDebug!

oesteves
New poster
Posts: 4
Joined: Wed Mar 05, 2014 8:20 pm

Re: 196 - Spreadsheet - RE

Post by oesteves »

Thank you again, Bryan!

There as "+=" instead of just a "=" in the col calculation. Now, answers are right. Runtime Error still survives! ;-)

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 196 - Spreadsheet - RE

Post by brianfry713 »

Post your updated code.
Check input and AC output for thousands of problems on uDebug!

oesteves
New poster
Posts: 4
Joined: Wed Mar 05, 2014 8:20 pm

Re: 196 - Spreadsheet - RE

Post by oesteves »

Sorry! Here it is:

Code: Select all

#define DEBUG 0

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>


/*
* DEFINES
*/
#define MAXN 1001
#define FALSE 0
#define TRUE 1
#define INF 2147483647

#define sFinalMatrix(a,b) resultMatrix[a+18279*b]

#define bool char

/*
* GLOBAL VARIABLES
*/
typedef struct
{
  int value;
  char resolved;
  char *p;
} cCell;

int iNumCols = 0;
int iNumRows = 0;

//static cCell sFinalMatrix[MAXN][18280];
//cCell resultMatrix[MAXN*18280];
cCell resultMatrix[1000*1000];


long iFnSumCell( char *str, int x, int y )
{
    long sum = 0;
    int i = 1;
   int len = 0;
   int rowN = 0;
   int colN = 0;
   long temp = 0;

  if(sFinalMatrix(x,y).p == NULL)
    {
      /* It is a pure number, return "column"*/
      return x;
    }
  len = strlen( str );
  if (len < MAXN)
    {
      str[len] = '+';
      str[len + 1] = '\0';
    }
  else len = MAXN;

  /* Check boundaries */
  if(x>MAXN) x = MAXN;

  if(y>18278) y = 18278;

  while ((str[i]) && (i<18278))
    {
      if( isalpha(str[i]) )
   {
     if(islower(str[i])) str[i] = toupper(str[i]);
     colN = colN * 26 + ( str[i] - 'A' + 1 );
   }
      else
   if ( isdigit(str[i]) )
     rowN = rowN * 10 + ( str[i] - '0' );
   else if ( rowN == x && colN == y )
     {
       rowN = 0;
       colN = 0;
       return -INF;
     }
   else if ( sFinalMatrix(rowN,colN).resolved == FALSE )
     {
       /* Checking Matrix boundaries */
       if(rowN > MAXN) rowN = MAXN-1;
       if(colN > 18278) colN = 18277;

       temp = iFnSumCell( (char *)sFinalMatrix(rowN,colN).p, rowN, colN );
       if ( temp == -INF ) return -INF;
       sum += temp;
       sFinalMatrix(rowN,colN).value = temp;
       sFinalMatrix(rowN,colN).resolved = TRUE;

       if(DEBUG)
         printf("test free1 row %d, col %d, string %s, mem %d\n", rowN, colN, sFinalMatrix(rowN,colN).p, sFinalMatrix(rowN,colN).p);
       free( sFinalMatrix(rowN,colN).p );
       if(DEBUG)
         printf("test free1 done\n");
       rowN = 0;
       colN = 0;
     }
   else
     {
       sum += sFinalMatrix(rowN,colN).value;
       rowN = 0;
       colN = 0;
     }
      i++;
    }
  return sum;
}

bool FnCalcMatrix(void)
{
  int r,c;

  for ( r = 1; r <= iNumRows; r++ )
    for ( c = 1; c <= iNumCols; c++ )
      if ( sFinalMatrix(r,c).resolved == FALSE )
   {
     long temp = iFnSumCell( sFinalMatrix(r,c).p, r, c );
     if ( temp == -INF ) return FALSE;
     else
       {
         sFinalMatrix(r,c).value = temp;
         sFinalMatrix(r,c).resolved = TRUE;
         free(sFinalMatrix(r,c).p);
       }
   }
  return TRUE;
}

int main(void)
{
  unsigned int uiNumSheets = 0;
  unsigned int uiSheetsIx = 0;

  /* Enter number of sheets */
  scanf("%d", &uiNumSheets);

  for(uiSheetsIx = 0; uiSheetsIx < uiNumSheets; uiSheetsIx++)
    {
      int iColsIx = 0;
      int iRowsIx = 0;

      /* Enter number of rows and columns*/
      scanf("%d%d", &iNumCols, &iNumRows);

      if(iNumCols > 18278) return 0;
      if(iNumRows > 1000) return 0;

      /* Rows Input */
      for(iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx++)
   {
     /* Cols Input */
     for(iColsIx = 1; iColsIx <= iNumCols; iColsIx++)
       {
         /* Check if it is a value or a formula */
         if ( scanf("%d",&sFinalMatrix(iRowsIx,iColsIx).value) == 0 )
      {
        int inputLen = 0;
        sFinalMatrix(iRowsIx,iColsIx).p = (char *)malloc( 2048 * sizeof(char) );

        if ( NULL == sFinalMatrix(iRowsIx,iColsIx).p) return 0;

        inputLen = scanf("%1024s", sFinalMatrix(iRowsIx,iColsIx).p );
        if(DEBUG)
          printf("malloc row %d, col %d, string %s, mem %d\n", iRowsIx, iColsIx, sFinalMatrix(iRowsIx,iColsIx).p, sFinalMatrix(iRowsIx,iColsIx).p);
        if (inputLen > MAXN) return 0;
        if(sFinalMatrix(iRowsIx,iColsIx).p[0] == '=')
          {
            sFinalMatrix(iRowsIx,iColsIx).resolved = FALSE;
            sFinalMatrix(iRowsIx,iColsIx).value = 0;
          }
        else
          {
            /* Invalid formula! */
            sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
            sFinalMatrix(iRowsIx,iColsIx).value = 0;
            sFinalMatrix(iRowsIx,iColsIx).p = NULL;
          }
      }
         else
      {
        sFinalMatrix(iRowsIx,iColsIx).resolved = TRUE;
        sFinalMatrix(iRowsIx,iColsIx).p = NULL;
      }
       }
   }

      FnCalcMatrix();

      /* Show Final Matrix - Results */
      for ( iRowsIx = 1; iRowsIx <= iNumRows; iRowsIx ++ )
   {
     for ( iColsIx = 1; iColsIx <= iNumCols; iColsIx++ )
       {
         if (iColsIx !=1 ) printf(" ");
         printf( "%d", sFinalMatrix(iRowsIx,iColsIx).value );
       }
     printf("\n");
   }
    }

  return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 196 - Spreadsheet - RE

Post by brianfry713 »

Input:

Code: Select all

1
93 26
14 88 =AL20+AW14+BF13 13 89 87 81 =BW5 =BM9 =CE24+AC5+CA20 44 94 =Y25+BB4 36 67 =BY19 14 48 =N23+AZ7+AL11 70 7 7 14 =CC2+AT8 4 25 43 22 61 73 94 29 =BN25+I9 50 =A12+AE4+BS9 =AZ4 81 =A18+L1 69 6 44 91 26 =BT23+AF13 22 =Z17 =BR23+AY4+BN8 =BJ21 =AS12+L11 =L24+V2+CJ7 11 33 80 16 2 32 =AD17 94 =CA20+AM9+BY10 =BN19+BW1 50 13 =Z5 =AU5+AM2+M25 77 =BQ17 =L9+I4+J20 66 47 =AK14+AG23 =BP2 1 =G4 61 =AR17 41 =R7+AY4+AH16 6 =CB12 47 =BL19+AH13+BQ25 =BY25 27 28 45 =AP13+CN1 0 35 98 =CE5+V9 48 =C15+CE1 63
81 =Z4+AU8 72 7 =BQ16+BT22 66 =R17+AY20 35 68 24 82 =AI3+CD12+S18 =AY1+BE5+L3 54 =AS16+BF3 =B14+CA20 =BQ6+CD22+CE3 0 =BT7 =BL9 34 =W9+T10 =BA10+Q8 =O10 =AY18 8 88 86 30 2 66 =CA12+P7+AX9 78 =BN6 47 =O12+W11 37 21 30 14 47 =BJ18 =BH8+U23 37 12 19 =P21+AY13+AC9 =BW23 =BA25 =CN8 18 =CA10 =BB7+AQ6 =AV24+AV18 82 11 34 15 =BV23 65 =AF2+AZ23+AO24 61 56 =BA16+AO19+AN20 0 18 14 51 48 32 43 =C8+BQ23 =AJ13+BN25+CH25 =CA14+AC2+CL2 38 27 =BK13 58 84 42 =Y9 99 54 =AC5 35 60 =J20+AP19 =Y17+BQ8+BL12 =BO5+BX5+AY7 =J23 69 =R1+CJ16+BR24 25
26 23 71 55 56 40 55 27 =L14 28 10 41 22 38 57 =K14 =B16+CA17+BR15 =CA18+BO14+AG16 =A26+BJ1+BF22 48 72 =CF16 20 =BY11 93 72 98 =CM14+AL17+AW23 =CC26 51 =BF11 87 =D8 =R10+CA12+AQ24 13 =AH21+AY19+BS9 42 =AW9+BG12 =O6 =C15+BS1 74 47 35 92 2 =AU18+W11 =AM23+V19+CJ23 =AZ19+X2 1 =CC23 54 =AD17+BO10+BT7 =CD14+BA10 =V10+AH1+BS4 =CH15 79 55 =CH25+BG24+CO24 =V4 98 =CE4 86 12 =CA6+S24+BC2 5 15 48 72 64 76 59 60 =BQ11+BM24+CA6 76 =CH7+CF19 93 75 11 =BH23+Z11+B5 31 18 =AP8 36 41 48 =BG8+AJ8 4 =BU4+Z1 =BG17+AO12 =AQ25+BY24+AF14 90 82 81
=BJ22+B26+F4 76 =AA18+BO1 =BG22+BE19+AH20 =M25+CF11 =S12 98 =Z25+G22 =AO19+CF11+CB22 =AL2+AJ1 =BD11+BS22+AI3 =BX4+AW16 =CE11 =AE26+AU3 34 =BA6 65 50 23 =AF24+AF9 =BY8+O1 17 =T16+AI19+C7 =AM6+W3 =AY13+U25 =X7+V25+BN10 =BY19+AA26+AF15 =BW21 =C2+BE24 11 41 =J2+AK9+BQ25 =M23 64 45 =AH24 =BW8+BT16 21 13 22 77 =BR18+O20+P2 =C26+CA9+X3 =AJ13 =BC10+L24 =L24+CN12+AW10 =BT26+AP2 18 =AU23+AU10 =BR3+BN3 =AQ5+X13+AO25 =CL23 62 =L14+E15 =M25+CA6+CG5 8 =BY8+AZ10+CC22 =CC13 =T9+BE13 20 45 33 76 64 =BB18+I9 25 23 =AE10 89 94 30 =H6+D8+U13 =CM14 =BF10+AP9 =BQ19 =BR13+BN12+V9 =BC12 =E22+B24 =AU8 =Y3+K18+AC24 =AX20+AI13+AI23 12 53 70 =A26 44 22 =W18+BQ14 64 98 =AY26+B22 36 =D5+U10+BS22
7 =J5 93 =CC13+AC24 16 =AM1 0 85 =CE5+BN25 88 =BS14+CC25 =BA7 63 32 =BM17 =AM23+CJ8 =BG5+AJ7 72 6 67 70 77 13 37 =BA25+U26 =CO10+E23+V14 62 =O24 83 22 70 =AU26+V10+CJ7 66 20 74 =AW8+BE22+AE10 =CL21 =CG7+AL26+V2 =AT22+U21+BP19 94 =AR3+AZ23 59 =AD17+BF26+BM19 =AL2+AH16 =BG12 67 43 92 =BY1+BB17 =P9+AB2+B14 =CH24 =AC26+E21 =AU9+K5 20 97 23 =I5+AZ11 33 =AP21+AG25+BS22 50 7 36 7 75 24 =V17+BV24 =CE4+BC12 87 =BN25+U10 =CD12+CO16 74 7 =BZ24 39 =AC18 53 =CF11 =L24 3 24 =BT10+N9+BO21 56 =N25 =CC2+BP11 36 42 46 =CC9 62 =BB19 30 =AX10 30
65 =L26+BM17 =CC22+AS12+T7 1 87 =BK25 69 12 90 =BX24+BT23+BR13 90 =B16+AJ15+BN12 =AP20 71 =AZ23+W8+AZ3 44 =CI16+A13 61 =Y18 =P21 21 =J23+U13+CE4 8 =AU26+CI22 =C19+BI16 =AP21 54 =N20+AN25 62 76 =L22+AZ6+U11 28 =C2 =J6 52 =CG25+C15+Y25 58 33 88 =U5+CE3 64 66 =AF12+AG16 =AU21+V14 =BN10+W6 =BJ1+A10+BZ11 =CH25+AZ2+C25 =BJ8+CA10 54 26 =AL9+J20 33 51 86 66 =BA19+T13 =BY8 =R1 =Y8 54 =BB5+CG20 =K1 =K3+AW23+CI24 =R6+AU12+AQ24 =BB13+AV21+AZ16 =AY14+BR10+BD26 =U7+BY6+CG8 =A5 96 =V2+V2+BH17 =BF22 67 =AK20 =AE14+BG18+BP20 =BK1+Z17+L22 =BX10+CD13 10 =CL18 =BH26 =O4+O11+AH19 =I8+AV17+BK11 91 6 96 66 =BG4 =BA20 33 =BR14+AQ3 =K19+BT23 47 =BW8+BN12+E19 =AN14+BP5
51 =AR23 86 =BI9 =CK22+Q19 13 =AW7 =AA16 =AS5 38 41 41 =BQ2+BQ3+AO8 0 20 21 21 11 39 96 73 =CE5 =BL21+CE13 63 =I25+AN8 =U17+AQ1 =U23+CB24+CD15 =T25 3 =CH20 =N10+X5+BP13 61 =AH8+V1+BY5 =AP25+BD12+BY21 =AZ3 86 77 =AI19 42 39 57 83 =W24+CD19 =BU4+AJ20 9 93 40 5 =V9+BU6+X13 =Y7+AU8+E19 =A10+AA3+AS16 3 2 62 29 =CD21+BC20 92 =BY1+A17 47 =AO15+AK25+BV13 =P12+BX6 =B6+BG8 =AP25+H1 =AP11+AA22 =BB19+Q16+L6 =CN17 =BF25+AH26 56 4 83 =AQ5+BC18 =AA22 =A26+AB15+BS2 =CA12+AX24+E23 =BF22+N26+BA25 =BE16 =Y21+E4 74 87 =AR11 =R10+AC5+L14 31 18 55 98 12 =BZ18+AD21 =AF23+AX20+AW23 83 =AB26+CK22 37 90 35
=I5 =AF1 16 18 69 =BY4+AG10 12 36 =AW16 =BA18+AC9+CK25 48 =CM10 90 =K4+CJ22+Y13 27 87 23 =BY17 =AU15+Q24 =CM3 =CF2 15 65 51 97 23 73 58 =CJ4+P6+AR2 68 =AN4 38 12 =AX19 86 44 67 68 =AW8+AM6+J18 60 =G22+CG2 77 43 32 =BS25+CD22 26 =BR24 =W10+CA14 =CK17+BB19 =AK20+K17 =CA18+BL21+AI2 36 =CE24+V4 =AK9+AT8+CN16 =BS2+BN14+R3 =AF15+AR22+BK24 3 30 76 4 83 =AG25+BM19 7 =U3+BL19+H25 =M21+CO19+R17 84 =F1 51 =U22+AO25+T2 27 =AD20+AI23 =AE11+AT3 17 =L2+AA18 21 =CF20 38 =BA21+X15 =CH5 =AV8+BA20+CO24 65 =AS4+AA9+AK11 =BA26+L2+BA11 =CD3+P11+S5 92 =R7+V23+BP8 95 =CG16+CF16 50 35 34 38 83
=BQ23+BZ11 =BN14 =CA9 17 =BU25 =BR19+AN4+U5 79 23 =BB22+M25+AX19 =CA12+AY1 72 67 =BC13+AP22 32 7 10 =BS22+BW4 =BD15+AI24+AD2 12 =AC24 =BQ9+BU19+W17 =AZ3+O6 53 18 69 13 =S18 =BI12+BK8 29 0 =Z15+CO7+BW26 48 =AS13+L2+BX17 85 =M15+BS26+AH20 =P21+X20+N22 11 92 84 =B14+AI10+AK5 =AI12+B7 7 56 2 =P12+AK20 =AW7+AW13+BN13 75 =CL6+CF26+BY21 =AP20+AU12+R5 =AN21+V25 77 =CH16+BB2+AG17 =BA17+V17 =BF3+D9+CA4 82 24 31 82 38 =G19 80 74 11 =BQ5 70 =AA9+AP11 =D24+AA11 40 =AP18+F15 =BV1+AT13 62 59 9 =BK12 =CH25 =X22 =BF4+H14+P12 78 =BE20+BD20+AD25 51 =B16+CF16+BK4 84 =AL14+BX13+BB22 =AK25+F1+A2 =BA10+J12 =C8+AW23 60 88 88 21 60 =BH9+AY19+BY1 33
=AY1+AW8+CI17 58 14 33 93 =M13+AZ19+CH8 =V15+AQ21 =E3 14 60 17 60 =AM2 =K3+AS12 =O12+CF22 =BC18+V25+AA9 11 82 =AQ17 =D5+X13 1 22 =BF26+CI17+CN22 =BK17+AK15 =L6 51 48 =I25+R7+AJ5 =AI24+CB19 =BI19+BI24 =W10+AY18+B25 =CN13 54 40 =CD18+BW8 94 =AV17+CF22 2 9 =AB11+BR22+CO25 66 66 76 =V1+P24 16 12 =CF11+M19 50 =BC3+H10+BO14 =O13 18 =AR15 =CN22+BE9 25 =BA4+BF1 =BG22+AP11+BW18 =BS24+X2+U5 =E23+S18+R19 =AZ24+U25+AU26 84 79 44 =BX10+BF9+BM19 =BM6 =AA9+C7 =AP12+CO19+K16 =BP24+CA12 =AI25+CH20 =BE5 30 =AF15+CO2 =BB5 71 =AA20+AJ22+AX17 =W24 29 61 =Z15+T10 =T8 80 3 22 60 12 83 =W13+BT10+Z20 40 79 40 =AB2+T17 95 =BO12 =BO10
=O6 73 =BF17 43 =X3 80 =AR11 90 =BA17 62 =AS23+BW8 =Q24+CB17+I3 17 10 =AC25+AZ6+AA18 =BE21 =J16+V2+BP24 =E4 91 33 =E4+CM9 =BC4+X12 38 =P19+X16 =BZ16+BP13 59 =J17 65 =Z15+AY23 =BU1+CG2+AY18 =L26+CG5 48 55 53 62 =AL8 58 7 1 =CA15 22 70 8 =G4 =CB25+CJ10 =AV17+AW20+CF11 =BF2+AU12+CO7 =BD22+AU21 =BJ19+BZ7 70 44 =AC24+AO8+BF4 50 =AS16+CJ6 58 =CG3+F13 =CD2 =X3+AP13+W6 88 =BI15+BR3+M11 21 =AT3 80 17 60 17 74 85 11 63 =AZ21 33 18 5 23 =R20 =CG2+CG2+CC13 =AC24+AJ7+BY11 45 22 60 51 =AR15+AQ24 8 16 =CN22+BT5 67 =AK25+AB2 88 36 =AA12 48 =C13
=Z16 =BE18+BU25+L4 54 81 =BZ19+BG17 =BR24+BZ22+AD13 =T12+AX20+BB16 29 2 55 =BT7+AP12+CK14 =U18+CH14+J13 41 =S12+BQ15+BR11 94 68 84 90 =BB26+L26+AH26 =AL11+X4 =B3+AB25 95 77 =CH5+AO13 4 =BX4 76 =K18 =E23 =Q9 =BL5+B16 8 =CK23 =AC16+A9+AD13 59 =R7+V19+AJ13 =BH18+AA16 40 23 =BV7+B12+O24 =N25 18 55 =R26 91 72 =Z1+BR13 40 47 89 =CN9+AG26 49 7 61 =E8+CI26 =Y13+BH4 49 31 =CC9+CG2+AJ15 58 =AD17+AG25+CA12 37 29 37 =BR6+E13 50 99 =P6 52 =AQ4 83 =AW8 81 35 70 =BN9 =M19 24 =L3+AC24+G22 73 =Q15 35 49 46 =AW26+O9 43 =BV22 5 =V12+BT25+AA24 22 60 79 8
45 71 =CO8+BX2+AR25 =A21+CK19 33 5 =AN9+BM23 64 61 =AH15+BF15 24 =AT1 59 64 0 =AD25+BR26+AF2 48 88 =AJ7 63 =AX8+M25+AZ3 =AU13+W10 87 =V9+BF26 80 =B5+AR8 21 =AC12 58 =CK17+AE10+S12 4 =CG16+BE16 44 47 94 =AH26+CF16+AG25 71 32 33 94 =P10+AQ5 1 =AR11+AQ21 65 6 =BJ10+AW13+C22 38 60 29 45 41 86 =BG5 =CO20+S2+CB1 90 97 43 =AE19 14 33 81 3 =BU1 97 81 33 9 =AM6 95 55 =BM16 31 =CM26 =AR17+S18 10 8 =AH7+AK19+CF6 =AO19 =AQ24 =AB19 =L3+L3 0 69 87 69 60 =BU25+BF4 =AP20+BP2+AU21 =BZ19+BN26+CH9 96 27 36 =BA25
39 =BZ19+W8+CG5 =Q19 33 92 80 0 43 =BJ7+BA14 =BO23+CF10 69 5 85 =AH22+BG17+X22 =BO5+BW23+BI24 45 96 =BE16+BD2 =W19 =G21 =BC10 =CK17 24 10 =BT17+M8+BJ5 71 46 43 50 17 =AB25 41 11 =AI17+Z26+W26 =BO3+A12+Y9 93 4 11 =AJ19+W5 =AX23+A25 63 79 92 7 8 =BQ3 =AF11 25 =BG22 20 =AB11+Z25+AT6 =AU2+AK24+AL7 23 =L9+BG9 12 =V3+AG1 54 4 31 =F7+BU19+G17 55 57 82 61 =CE17+U1+BE6 84 5 =W6+M21 43 =BH26+AP18+BJ1 =CE13+BK4 =BI12 =P1+A23+BV20 95 18 =AN17+BR26 43 =CB22+BP8 =B6+B20 50 =BP24+BF26+AA20 38 3 =CJ20+AV17+BT18 48 =CK14+C20+BZ16 3 23 58 =CN16 =AO8 72 =AA20+AG8
=CO24+BJ11 =L3 20 =O4+AO4+BO8 =AO20 =BT16 =O1 =S16 40 87 68 61 =I19+AK4 13 79 =BX8+BL8+AM2 =BB3+AN18+BV8 =BW5+G22 75 =E18+AC12 30 =I16+L24 70 =AF1+CN26 =AF11+CC24 =BB2+AY7+BX13 1 41 =AR16+AL11+BW26 =R7 =CD8+CL11+T12 16 =BM17+BU17+AF1 =AP21+AE10+BQ5 =BS21+L26+BP3 =AP18 =A8 =CE7+Q2 91 =CG15+AB10+BU6 =CE26 68 75 46 =BS26+I17 53 68 =AD24 99 1 60 22 =BT26 =AG12+M23 =X3+M13 24 =AZ18+BC11 =BX6 91 38 =BF20+AA3 69 76 55 74 46 =CM7 98 52 =BT7 =CM3 59 99 15 =BK3+AI9 33 =CH21+BY17+CL3 =BV4 59 3 =Q19 77 44 =BE19+AW14+AZ11 =T17+AI18 91 =CG2 =A5+B14 28 =AV17+AD22 49 46 =T10+I22+AK10
=BM9 71 =BS1+L4+C4 =AP9+BF6 =R12+U10+AO20 =AM6 43 92 31 6 =W6+AG25 0 78 =AH1 66 =BC22+BZ10+AN26 54 =AE3 21 17 =AN8 54 94 =BK4+K17+AN21 49 19 29 43 =BM19+AK2+CF11 55 =BO23+BK9 =Q25 98 =BE22 45 =AU25 =AL18+AZ20 63 83 =AY16 3 45 90 =N25 =CI26+BF24 =M7 72 =AM1 =W12 90 36 89 25 45 =F24+AC7 91 =R17+AU5+CM6 =H25+W18 33 =E4 =BT26+AZ6 24 =P12+CE8+AS5 7 =AG17 =BG2+O3 32 24 22 =CO16+Y22 18 =B16+AJ7+AL2 91 37 =AA16 22 =AP15 =BN25+G22+G22 21 11 =G10 =P12+BU4 =L26+G4+R17 =CC13 =AC16+X16 =AZ3+AZ21 95 98 18 4 =R7+AH11 =AM17 =AP21+AA3
=AA13+BT16+BW23 =CI17 =AI24+AG16+AH19 20 =CB9 =W10 31 =AB26+AD24 24 =AI10+BM1 =BI12+BO10 =U5 =AT8 27 88 42 =Y17 18 13 =BQ11+AM6+BJ1 =BW13+AM6+AA25 57 88 84 38 51 11 =BK5+AD15 =Q9+AL2+AA16 =M25 47 52 99 32 =AD17+AP6 =BX16 =BS25+AP25 73 44 0 =AG25+AN12+CO5 42 =BM20 75 =BQ22 16 46 96 23 =AX5 55 80 5 =BO10 =BT12+BQ22 60 59 5 65 =R17 96 47 88 =BP9+Q26 =AX8+BT16+K17 =CL10+AL26+AE12 =CD8+AB6 16 0 =BU12+AX22+AW15 61 58 63 =BA21+V11 5 96 =V3+AU15+BY6 17 =BY11 =CI9+Z1+BY22 60 =CA24+U10+AR13 4 50 =CM14 =I12+BC6 8 93 56 78 41 64 =AW14+CO16
=X8+BU5 =AZ18+AE2 16 90 =AF9+BP8 =T12+AA26 =AC3 =AS2+Z9+E4 =BX13 18 =G4 98 94 =BK23 =BS11+BZ26 93 =AJ24+CG8+BA22 =S12+BF21 =G22+BT16+AS16 =W5+CO16 21 =AK25+BT1+CI4 =I12 78 48 =AK26+BW4 54 24 =BK4+N25+BE22 22 =CC2+CL23 68 58 =Y16+CN2+Y19 38 =D11+CM3+BB26 =BZ4 =CH5+AO7 25 55 =BH11+BH18 10 9 84 1 =BZ16+BK11+BU1 41 31 =BE7 =AS21+AE26+AR12 =AJ15+L26 =F22+AF11 =BT10+J5 =CI14+R16 =BQ3+R7+Z1 62 =BA23+CG15 90 20 87 =P24 =BX19+BS1+BK10 19 59 37 79 41 45 =AU15+BJ24+BA17 =BT8+AH8 =BF3+H4 =AX12 80 75 50 29 95 81 24 =BC3+AT14+Q9 15 65 =B14 =AF7 =CN19+BN2+CG12 =BF4+BW20 =BB10+CM5+BO23 =CJ3+AQ11 =AX8+AB11+Z1 92 =BI14+BO10 87 16
=J23+AP15 =K5+CG17 26 =CN16+BM8 =W9 =BS8+BL1 59 =BT12+BK24 =BK15+R7+CK17 21 86 36 81 =AR11 28 76 =CE5+AU2 =CB24+BX24+BQ10 =AY15+AS16+O12 73 =BB5+W13 74 14 37 =P12+CA23 88 =H21 19 49 62 94 =BJ10+BD13+AC5 66 21 51 79 =CG20+AY8+AU2 33 =BX16+CL24 78 81 =U21+AR15+BI5 97 =AU24+O12+P26 99 =CE7+AK8 75 =BA5+Y22 4 =BS3+BG5 =C8+BK15 74 49 58 =BC16 =CB11 20 92 =I16 =CD21+K16+AH13 =J7+BS21 8 =AE2+BS1 =CI19+CH10+J7 =BW8 =CA10+CL10 89 32 19 =AM16+O10+AH1 =CL18 =AB22+CN22 95 65 =BK19+D5+BF9 =BY11 88 =AS16+BF26+CO4 50 3 =S25 =E13 16 =AK20 =L9 66 =AJ23+AO23 =BJ12 =BW17 =T17+AU18 9 =G1 16
31 =AJ13+AH13+AR15 90 45 64 =R16+AF24+BO15 =BP4+BU9+BC22 =G6 =BA8+BW17+AW1 =AO8+CD18+BX13 =S2+BI24 =BU23+BA12+CB24 =N9+BN10+AD18 32 =BW3 72 =BT7+BA8+BZ20 71 =P12+BL13+BU17 88 =AA22+I19 87 =BT1+BT10 =AK20+AI23 =S18 91 =CH5+BJ12+AL2 =X18+W22+E12 66 7 =U25 50 54 =R12+AX8+AZ23 =AR15+CK18+BR23 =AZ9+BX4+R7 33 20 =Z1+B18 =CG4+BN24 32 73 =S3+AP12+BT22 =AH15+I4 21 =CA24 52 =BV19 45 =L14 43 =BH26+BQ4 71 =BJ5+BK7+A12 =CG3+AA18 =CD18+AN19 73 78 6 =BD5+R7+E19 50 91 =BR10 =CE11+CD9+AA13 25 3 =BN25+BJ10 38 =S21 =T19+BR19+AD6 16 =CG2 3 14 85 =CL9+A11+V2 =AF1+B4+Z9 63 78 21 95 94 =BX19+AP8 79 =AR22 =BF24 =BP17+AN16+AR8 66 =E4 =BA21+AI19+AH13 40 66 =S2+CF16
=BS14 20 =CG16+AU12+AO16 5 =AF23 =BP2 56 57 11 57 =L24+AG16+AV24 30 96 46 95 97 69 =CK17+CE26 47 28 =BE20+BK4+BP8 77 =AJ12+AY13 =K12 =Z12+BY25+CO10 =AM6 76 =K1+S3 56 57 30 =BW17+BO26 =AP13+CD19+BF26 68 23 32 =K12+CD15 76 =CA6+AC24+BZ11 28 10 =BQ3+CK25 =AY7+BA17 =BN26+CB24 =BC10+I13 35 =K12+BT5+V14 =CE16 =AR11+CC11 =G22+I2 =BZ21+J25 =A26+AU8 =BA20 82 68 74 50 =AK20 =CI8+AU5+Y7 =AK7+T22 =CB21+C9+BQ8 =BU11 =V9+AG25 =J6+AL14 =AP6+BY12 =CL18 =AU5 8 90 28 =CM16+B22+AB22 46 =BE19+B6 =AF14+AZ8+T7 92 =CE14+BZ23+BT1 =BJ10+BX2+AZ7 30 88 =AG21+BI2 =BU10+AM18+BJ9 63 77 78 =BE9 29 82 37 =AY26 =BG8 =CC17+AM21 97 42
=CF4+R7+K26 94 31 =BF8 86 33 =CC13+BQ3 0 =BY11+BM18 =BS16 62 98 =BK4+CC14+CN3 =Z15+BR14 =D15+BJ7 72 77 =CO21 12 93 17 9 =G26+BK25+K4 75 =E13+AI17+CB4 54 79 66 45 =BY24 67 0 42 =B1+AR11+P21 =BL8+CD20 =BI9+AA9 6 41 14 63 =BO23 98 70 46 50 =BN13 69 =S9 55 16 =AG20+AO8 =CO8+BW18 =BR15 17 =BT16+BE5+BQ11 =AW7+AI13 69 =AS16+R7 =Q9 38 60 81 5 =K16+O14 =C10 =AI10+A10+M25 =CI17+CI8 73 23 =CN22 =M25+CK17+AO8 =AF13 =AH22+AM7+AG19 98 =T10+CB6 =AZ15+D21 15 =J16 78 =AO12+BF24+BQ11 68 =T17+CJ5+T9 =R5+Y18+BJ5 =N25+BD16 46 38 =BO7 =BT12+X3+CN22 60 =J1+I3+BM12 4 5 =BO24+BX16+AJ18
=AO12+AU25+BF11 48 =AT20+AD17 =CE23+AY6 26 70 =AH4 29 =D9 14 =BC22+AP6 23 7 38 82 =S18 =BS3+BV15 53 =BE22+BA23 51 =H24 =E3+AI18+Q9 86 96 =AN9+AO8+BS6 =AQ26+AG12+AI23 =CE12+BD23+J9 77 42 =AR9+AW3 44 16 10 48 47 =BV24+AO8+AY19 18 =CA9 83 15 =BU23+BX13+CI4 19 =AK2+CA15 =CO19 =Y3 =V19 8 =CF22 =C8+BI12+R7 20 87 =CG2+AR17+BH26 18 94 =V20 65 =C16 49 24 60 =BG18+BS25 81 12 =Z20 62 =BO7+BP4+BJ16 =AT8+AM17+BF8 66 60 =CN23+BZ19+AP15 =AP12+K12+A26 50 =AP25 16 =CI26+BQ11 10 45 =CE16 =CF25 50 =BX13 =AR17+W8+CF16 95 29 =AX3+AO22+CK19 94 =CF24+Q24 9 12 13 62 67 85
82 61 =BH25 =CB4+AQ20+O9 =AX1+AX5+P18 50 =BP13 =BF11+P16+BA19 90 38 =CB4 13 32 93 =AL6+X18 35 =I16+BD13+AJ7 88 36 =CB12+AT23+J7 29 =BE7+AK9 =I4 =BX13+AL8+BA3 48 79 52 =CI24 70 =BW8 =BB2+CA23+CO7 =CI26+AR23 =CO14 14 9 45 56 66 =Z5+BU20 91 =CE13 =BL20+AZ21 19 62 70 63 =CE10+CO19+BO18 64 33 83 =CE16+CK25 94 =CK17 19 =CH15+W26+BX5 =C8 83 =BP24+I5+BJ1 95 26 80 12 =BG12+CH14 11 =CH16+CO1+AY7 =BR14+AP6+CH24 =CF3+AR3+L14 =AJ15+AC24+BY11 0 =CG3 10 =AR1+A10+AO9 93 31 99 39 76 3 =BC22 53 =AR13 =AP6+W24 =AQ4 =CN17 =BI18+O2 =K16+CF11 62 39 28 82 =J23 95 25
=BW8+Y7+CC13 =CB22+CK25+Z1 42 39 =BH24+R16+AF8 42 =Z16+AW13 23 26 =Y6 =CE24+U12 5 59 =CC13+AP18+BQ3 88 =AU25 =AD10 23 =AO25+AR5 =BL22 32 82 96 =BT22 =CG16 57 =A12+CF5 27 =B6+CG3 =CB17 54 5 =AD17+BF4+BF4 =V9+CA14 =BS14+S25 82 =U10+F14+BS7 =AI19+E11 7 23 14 =E23 =AQ23+CN12 =K17 =C26 9 11 =AD19 =I11+CE5 =R22+F21+AQ22 =CH10 =CN22+AD22 =BG18 =CC14 23 9 =BP3 =CJ9 =P2+CG12 85 =BN24+CI4+BS1 91 92 =A19+L6 =BS11+U12+CH17 15 77 =CB16 27 =CK25+AL17 71 56 =AZ21+AP21+AY14 92 34 =BF4+BR24 31 35 =BT14+AL7+BG3 4 18 =AV18 =AE10+N25+BI25 74 8 =BS4+Z1 87 =N15+AY19+AR15 =AP12 55 93 =U23+J18+AN9 =C7+Q11
70 20 60 =BI15+AT19 =X24 67 63 =I22+J8+CF26 4 =AL11+AT15 92 8 =CK2 99 =CJ13 16 =A10+CH25+AW8 98 19 =BD19+CC25 4 2 96 41 51 81 11 96 =Y12+BL22+AD5 =C7+AM17 =AD14 =CD12+AY4+T10 =O9+CH24 46 =BB22 =Z4 51 83 62 =G4+BT26 =AY26+M14 =W8+AH5+S2 72 64 =AT6 =C8 40 =BE8 =AF15 80 =J21+AR23+BP24 =BJ15+E10+BL25 =CO19+BX4+I5 =AR11+CB1+BV20 =AZ2 14 =BR22 =F14 =P10 =BD26 76 =CM6+BE16+AZ23 15 42 =CI19+D8 =D5+CD17+CO10 =CN22 =AX8+A12+AA16 36 =AJ23+CF11+CA18 29 55 =V25 7 =CI17 15 =X1 =BS3+AP18 29 =BM12+BN10 15 26 45 94 =E20 4 =G22+N25 =BV8+BW16 =CL23+BZ23 22 =BQ10+BF24+BZ16 =B20+AD24+CM7 =BO8+AF23+CM24
your code is throwing a seg fault in scanf.
Check input and AC output for thousands of problems on uDebug!

anacharsis
Learning poster
Posts: 69
Joined: Mon Feb 09, 2015 1:56 am

Re: 196 - Spreadsheet

Post by anacharsis »

Just a heads up for people reading this thread for pointers on how to get accepted.

1) Some posters suggest you add a newline between the spreadsheets that you've calced and printed.
Don't; if you do this, you don't get a presentation error, you just get a flat out wrong answer judgement.

2) This test case that's posted above isn't valid:

1
2 2
=B1+B2 7
=B2+A2 6

Cell A2 contains a circular reference.
For some reason, and somehow ( presumably by short-circuiting and calcing what it can ), the UVA toolkit produces an answer.
But this isn't a case that comes up in the judges test inputs, or I wouldn't have passed.

Hope this helps

Post Reply

Return to “Volume 1 (100-199)”