問題一覧 > 通常問題

No.2080 Simple Nim Query

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 78
作問者 : taiga0629kyopro / テスター : 👑 AngrySadEight ygussany
お気に入りにしたユーザー ProblemId : 8437 / 自分の提出
問題文最終更新日: 2022-09-18 18:01:04
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 contest 361 (順位表) の他の問題:

Problem Statement

Taiga created the following problem.

Simple Nim

F and S play a stone-taking game using an integer sequence $(C_1,C_2,\dots ,C_k)$. Initially, $k$ piles of stones are arranged in a row from left to right, and the $i$-th pile from the left contains $C_i$ stones. Starting with F, the $2$ players alternately repeat the following operation.

  • Choose the rightmost pile among the piles with $1$ or more stones remaining. If that pile has $n$ stones, remove any number of stones between $1$ and $n$, inclusive, from that pile.

The player who first becomes unable to perform an operation loses. Which player wins?

You are given an integer sequence $A$ of length $N$ and $Q$ queries. In the $i$-th query, three integers $T_i,X_i,Y_i$ are given. Process it as follows.

  • If $T_i=1$, replace $A_{X_i}$ with $Y_i$.

  • If $T_i=2$, output the answer to the problem "Simple Nim" with $C=(A_{X_i},A_{X_i+1},\dots,A_{Y_i})$.

Input

$N$ $Q$
$A_1$ $A_2$ $\dots$ $A_N$
$T_1$ $X_1$ $Y_1$
$T_2$ $X_2$ $Y_2$
$\vdots$
$T_Q$ $X_Q$ $Y_Q$

  • $1 \le N \le 2×10^5$
  • $1 \le Q \le 2×10^5$
  • $1 \le A_i \le 10^9$
  • $T_i$ is $1$ or $2$
  • If $T_i=1$, then $1 \le X_i \le N$ and $1 \le Y_i \le 10^9$
  • If $T_i=2$, then $1 \le X_i \le Y_i \le N$
  • All input values are integers
  • Output

    For each query with $T_i=2$, output F if F wins "Simple Nim", and S if S wins.

    Sample

    Sample 1
    Input
    2 1
    2 1
    2 1 2
    Output
    S

    Here, $C=(2,1)$. At first, F has no choice but to take $1$ stone from the $2$-nd pile from the left. Then S can win the game by taking $2$ stones from the $1$-st pile from the left.

    Sample 2
    Input
    2 1
    1 2
    2 1 2
    Output
    F

    Here, $C=(1,2)$. First, F takes $1$ stone from the $2$-nd pile from the left. Then S has no choice but to take $1$ stone from the $2$-nd pile from the left. Therefore, on the next turn, F takes $1$ stone from the $1$-st pile from the left and wins.

    Sample 3
    Input
    3 3
    3 1 4
    2 1 2
    1 2 2
    2 1 3
    Output
    S
    F

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