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

建议使用的浏览器:

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

2650:Spaghetti

题目描述
Early languages like Fortran IV use conditional and unconditional goto statements instead of structured statements like if and while. In Fortran IV, each statement occupies a line of input. The first five positions in each line are reserved for an optional label, which is an integer. The next position is reserved for a continuation marker, which we shall not consider further. Therefore, statements occupy positions 7 and beyond in each input line. The goto statement looks like this
      goto label

and the conditional goto statement looks like this
      if(expression)goto label

The language contains many other statements, but only the conditional goto begins with "if(" and ends with ")goto label" where label is an integer. All spaces are ignored within a Fortran IV statement. For this problem, the "stop" statement, which halts execution, appears only as the last line of the program.
Your job is to determine whether or not two Fortran programs are equivalent. They are equivalent if, for all possible inputs, they execute exactly the same sequence of statements, ignoring unconditional gotos and labels. By "the same sequence of statements" we mean statements that are textually identical, after spaces and labels are removed. You must assume that each conditional goto will be taken for some inputs and not taken for others. Unconditional gotos are, of course, always taken. The two programs in the sample input are equivalent.
输入解释
Your input consists of two programs separated by a blank line. No input line exceeds 80 characters and no program contains more than 1000 lines. Each label used in a goto statement appears to the left of exactly one statment; no label is repeated.
输出解释
Output consists if a single line, stating either "The programs are equivalent." or "The programs are not equivalent."
输入样例
      read 6, i,k,j
   99 if(i .lt. j)goto 33
      goto 55
   33 i=j
      goto 99
   55 k=j+1
      stop

      read6,i,k,j
      if(i.lt.j)goto12345
77    k=j+1
      goto5555
12345 i=j
      if(i.lt.j)goto12345
      goto77
88    goto88
5555  stop

输出样例
The programs are equivalent.

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

源链接: POJ-2650

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

共提交 0

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