問題一覧 > ネタ問題

No.8117 Simple Programming Language

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 256 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 57
作問者 : 👑 loop0919 / テスター : yimiya(いみや) Iroha_3856
お気に入りにしたユーザー ProblemId : 12027 / 自分の提出
問題文最終更新日: 2025-04-02 21:43:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2025 (順位表) の他の問題:

Problem Statement

for-loop-san, who loves simple and refined things, has created a programming language "Simplang" in which nesting of depth $\color{red} 2$ or more is impossible.

Using Simplang, write a program that solves the following problem.

Problem
Problem Statement

You are given $2$ grids with $H$ rows and $W$ columns, called grid $A,~$grid $B$, respectively.
The cell in the $i$-th row from the top and the $j$-th column from the left of a grid is called cell $(i, j)$.

Cell $(i, j)$ of grid $A$ contains the integer $A_{i, j}$, and cell $(i, j)$ of grid $B$ contains the integer $B_{i, j}$.

Here, it is guaranteed that there is exactly one cell $(i, j)$ such that $A_{i, j} \neq B_{i, j}$. Find that cell $(i, j)$.

Constraints
  • $H, W$ are integers satisfying $1 \leq H, W \leq 10$.
  • $A_{i, j}, B_{i, j}$ are integers satisfying $1 \leq A_{i, j}, B_{i, j} \leq 100$.
  • There is exactly one cell $(i, j)$ such that $A_{i, j} \neq B_{i, j}$.
Input
  • $H$ is given as the constant H.
  • $W$ is given as the constant W.
  • $A_{i, j}$ is given as the constant A[i,j] ($1 \leq i \leq H, ~ 1 \leq j \leq W$).
  • $B_{i, j}$ is given as the constant B[i,j] ($1 \leq i \leq H, ~ 1 \leq j \leq W$).
Output

Output the answer $(i, j)$ using the return statement.

Sample
Input
H: 3
W: 3
A: 1 2 3
   4 5 6
   7 8 9
B: 1 2 3
   4 5 6
   7 9 9
Output
(3,2)

Cell $(3, 2)$ of grid$A$ contains the integer $8$, while cell $(3, 2)$ of grid $B$ contains the integer $9$.

Thus $A_{3, 2} \ne B_{3, 2}$, so output $(3, 2)$.

An overview of the Simplang language specification is given below.
Note that if you output a Simplang program that does not satisfy this specification, the judge result will be WA.

Overview of the Programming Language "Simplang"

The notable specifications of Simplang are as follows.
For sample programs and the source code of the interpreter, see Qiita: yukicoder April Fool Contest 2025 "Simple Programming Language" (limited access).

  • Value literals can be integers at least $0$ and less than $10^{100}$. (For example, to define $314$, write 314.)

  • Variables can be used in the form $n (where $n$ is an integer at least $0$ and less than $10^{100}$).
    • For example, $0, $1, $998244353, and so on can be used.
  • All variables are initially initialized to $0$.
  • A value is assigned to a variable in the form 変数 = 値 (variable = value). For example, $1 = 2 assigns the integer $2$ to variable $1$.

  • To compute values, the binary operators +, -, *, /, % can be used.
    • + denotes addition. For example, $1 + $2 denotes (variable $1$) $+$ (variable $2$), and $1 + 1 denotes (variable $1$) $+$ $1$.
    • - denotes subtraction. For example, $1 - $2 denotes (variable $1$) $-$ (variable $2$), and $1 - 1 denotes (variable $1$) $-$ $1$.
    • * denotes multiplication. For example, $1 * $2 denotes (variable $1$) $\times$ (variable $2$), and $1 * 10 denotes (variable $1$) $\times$ $10$.
    • / denotes floor division. For example, $1 / $2 denotes the largest integer not exceeding (variable $1$) $\div$ (variable $2$).
    • % denotes the remainder operation. For example, $1 % $2 denotes the remainder of (variable $1$) divided by (variable $2$).
      • Note that the specifications of floor division and the remainder operation differ from those of C, C++, Java, and so on.
  • The order of evaluation is the same as in ordinary arithmetic (except that the remainder operation has the same precedence as multiplication and floor division), and parentheses () can be used to change the precedence.
  • During computation, you must not produce an integer $x$ that goes beyond the range $x < |10^{100}|$.
  • During computation, you must not attempt floor division by $0$ or take a remainder when dividing by $0$.
  • Note that unary operators and compound assignment operators do not exist.

  • Each constant can be used as a value, but no new value can be assigned to it.
    • For example, $0 = A[H,$1] assigns to variable $0$ the integer written in cell $(H, $ variable $1)$ of grid $A$.
  • For A[i,j], B[i,j], $i, j$ must be integer values satisfying $1 \leq i \leq H, ~ 1 \leq j \leq W$.
    • Note that they are 1-indexed.

  • As control structures, only if - end statements and while - end statements can be used.
    • What is an if - end statement?

      An if - end statement is a control structure written in the following form.

      if(条件)
        条件が真であるときのみ実行される
        ...
      end
      

      For example, a program that takes the absolute value of variable $1$ is as follows.

      if($1 < 0)
        $1 = 0 - $1
      end
      
      What is a while - end statement?

      A while - end statement is a control structure written in the following form.

      while(条件)
        条件が真である間だけ繰り返し実行される
        ...
      end
      

      For example, a program that stores the sum of $A_{1, 1}, A_{1, 2}, \cdots, A_{1, W}$ in variable $0$ is as follows.

      $1 = 1
      while($1 <= W)
        $0 = $0 + A[1,$1]
        $1 = $1 + 1
      end
      

  • The condition of an if - end statement or a while - end must be written in the form 値 op 値 (value op value) using a comparison operator $op$.
  • The operations available as comparison operators are as follows.
    • <: True if the left side is less than the right side, and false otherwise. For example, $1 < H returns true when (variable $1$) $<$ $H$.
    • <=: True if the left side is less than or equal to the right side, and false otherwise. For example, $1 <= H returns true when (variable $1$) $\leq$ $H$.
    • >: True if the left side is greater than the right side, and false otherwise. For example, $1 > H returns true when (variable $1$) $>$ $H$.
    • >=: True if the left side is less than the right side, and false otherwise. For example, $1 >= H returns true when (variable $1$) $\geq$ $H$.
    • ==: True if the left side is equal to the right side, and false otherwise. For example, $1 == H returns true when (variable $1$) $=$ $H$.
    • !=: True if the left side is not equal to the right side, and false otherwise. For example, $1 != H returns true when (variable $1$) $\ne$ $H$.
  • A condition cannot be assigned to a variable.

  • When answering cell $(i, j)$, write the return statement on the last line of the code in the following form.
    • return(i,j)

  • Nesting of depth $\color{red} 2$ or more is not allowed.
    • What does "nesting of depth $2$ or more" mean?

      A program has nesting of depth $2$ or more if there exist $1 \leq i < j \leq P$ (where $P$ is the number of lines of the submitted program) satisfying the following conditions.

      • Both line $i$ and line $j$ contain end as a substring.
      • For every $k$ with $i < k < j$, line $k$ does not contain if, while as a substring.

      For example, the following program has nesting of depth $2$ or more, so it is not a valid Simplang program.

      $0 = 0
      $1 = 0
      while($0 < 3)
        if($0 == 2)
          $1 = $0
        end
        $0 = $0 + 1
      end
      return($0, $1)
      

      Conversely, the following program does not have nesting of depth $2$ or more, and it is a valid Simplang program.

      $0 = 0
      while($0 < 3)
        $0 = $0 + 1
      end
      if($0 == 3)
        $1 = $0 + 1
      end
      return($0, $1)
      

  • All half-width spaces and tabs in a program are ignored at execution.

  • The program must have at most $100$ lines, and each line must contain at most $100$ characters (including half-width spaces and tabs).
  • When the program is executed, the total number of executions of all lines must be at most $10^5$.
    • A concrete example of the flow of program execution

      For example, consider the following Simplang program.

      $1 = H
      while($0 < 2)
        $0 = $0 + 1
        $1 = $1 - W
      end
      return($0, $1)
      

      In this case, it is executed in the following order.

      1. $1 = H: The constant $H$ is assigned to variable $1$.
      2. while($0 < 2): If variable $0$ is less than $2$, the body of the while - end statement is repeated. Since variable $0$ is initialized to $0$, the condition is satisfied.
      3. $0 = $0 + 1: Variable $0$ $+$ $1$ is assigned to variable $0$.
      4. $1 = $1 - W: Variable $1$ $-$ constant $W$ is assigned to variable $1$.
      5. while($0 < 2): The condition is checked. This time, the condition is satisfied.
      6. $0 = $0 + 1: Addition is performed in the same way.
      7. $1 = $1 - W: Subtraction is performed in the same way.
      8. while($0 < 2): The condition is checked. This time, the condition is not satisfied, so execution jumps to immediately after the end statement.
      9. return($0,$1): The answer is $($variable $0$, variable $1)$.

      In this way, the processing completes in $9$ executions.

Input

There is no input from standard input.
In the judge, $H, W, A, B$ are given to the Simplang program printed to standard output.

Output

Print to standard output a Simplang program that finds the cell $(i, j)$ satisfying the conditions of the problem statement.
If you write Simplang code directly, you can submit it as is by selecting Text (cat 8.3) as the submission language.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。