Spreadsheet | 프로그래밍의 벗 PivotOJ
PivotOJ

Spreadsheet

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2004 SeniorBOJ 6894

문제

A spreadsheet consists of a number of "cells" set in a rectangular grid. Each is addressed with one letter from AA to JJ (giving the row) and one number from 11 to 99 (giving the column). Thus the upper-left cell of the spreadsheet is A1A1, and the lower-right cell is J9J9.

Every cell has a value, and this can be specified in one of two ways:

  1. as an integer from 00 to 10001000
  2. as a sum of the values of up to 1010 other cells

Cell values may be interdependent (that is, A1A1's sum may depend on B6B6 which depends on C9C9), but a cell whose value depends on itself, directly or indirectly, is undefined (e.g., A1A1 depending on G8G8 depending on A1A1). Also, a cell whose value depends on an undefined cell is itself undefined. You are given the specification for all the cells in the spreadsheet. Compute and output the values of all of the cells.

입력

Input will consist of 1010 lines, one per spreadsheet row. Each line contains 9 descriptions of a cell, which will be either an integer between 00 and 10001\,000, or a sum of 11 to 1010 distinct cell names separated by a + symbol (e.g. A1+B5+D3).

출력

Output 1010 lines, with 99 numbers per line, giving the value of every cell in the spreadsheet; if the cell is undefined, print an asterisk (*) in place of its value. No cell's final value will exceed 10000000001\,000\,000\,000.

예제

예제 1

입력
1 2 3 A1+A2+A3 A3+A4 A1+A4+A5 A8+A9 A9 A8
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
출력
1 2 3 6 9 16 * * *
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
코드를 제출하려면 로그인하세요.