22306_Spaghetti

2022-5-16 18:21| 发布者: Hocassian| 查看: 29| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506308758599-Problem List-采集的数据-后羿采集器.html

Pro.ID

22306

Title

Spaghetti

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22306

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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.

    输出

    Description

    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.

    Input

    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

    Output consists if a single line, stating either "The programs are equivalent." or "The programs are not equivalent."

    Sample Input

          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

    Sample Output

    The programs are equivalent.

    Source

    样例输入

          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.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部