当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2320:SHEET

题目描述
See if a spreadsheet has a consistent formulation.
Any given cell of a spreadsheet can have a formula that depends on the value from some other cell. Before trying to calculate the value of a cell it is important to determine if the definition of the formula for that cell is circular.

Our spreadsheet only has a limited formulation for expressions:
definition := cell "=" expression

expression := term | expression "+" term | expression "-" term
term := factor | term "*" factor | term "/" factor
factor := number | cell | "(" expression ")"
number := digit | number digit
digit := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
cell := "R" digit digit "C" digit digit

Valid cell rows and columns are 1 through 20, so that a total of 400 cells are available in our spreadsheet.
输入解释
The input will contain one or more lines, each representing cells that are defined in the spreadsheet.
Note that, if an expression in some cell refers to some other cell, the contents of that other cell will always be defined.There are no white space characters in the expressions.
输出解释
A single line is printed for each cell defined in the input(and in the same order). This should be the cell name followed by "circular" if evaluating the cell results in a circular definition (either directly or indirectly). If the cell can be evaluated without a circular definition, then the word "ok" should follow the cell.
输入样例
R01C01=1
R01C02=2
R01C03=R01C01+R01C02
R02C01=(R03C02+1)*R01C03
R03C02=R02C01
输出样例
R01C01 ok
R01C02 ok
R01C03 ok
R02C01 circular
R03C02 circular
提示
Clarification
The following spreadsheet would have two circular results

R01C01=0*R01C01
R02C01=R02C01-R02C01

Point is, don\'t do algebraic simplifications before determining circularity.

Q. If a cell references a cell that is circular, is the cell defined as circular even though it does not reference itself?

A. Yes.

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Rocky Mountain 2003

源链接: POJ-2320

最后修改于 2020-10-29T06:29:43+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536