問題一覧 > 通常問題

No.627 Trajectory of a Random Walk

レベル : / AI推定難易度 : 111 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 519
作問者 : ats5515 / テスター : ciel
お気に入りにしたユーザー ProblemId : 1892 / 自分の提出
問題文最終更新日: 2026-06-26 08:49:03
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 179 (順位表) の他の問題:

Problem Statement

A random walk generally refers to a motion in which the next position is determined randomly.
Here, consider the following random walk of a point P on a number line.
・At time $t=0$, point P is at the origin.
・When P is at coordinate $x$ at some time $t$, at time $(t+1)$ it moves to coordinate $(x+1)$ with probability $\frac{1}{2}$ and to coordinate $(x-1)$ with probability $\frac{1}{2}$.
You are given a sequence $X_i$ of length $T$. Determine whether this sequence can be a record, in order, of the coordinates of point P from time $1$ to time $T$.

Input

T
X_1
X_2
...
X_T

$1 \le T \le 100$
$-100 \le X_i \le 100$
The first line contains the length $T$ of the sequence.
Each of the following $T$ lines contains the coordinate $X_i$ of P at time $i$.

Output

Print "T" if the sequence $X_i$ can be a record, in order, of the coordinates of point P, and "F" otherwise.
Print a newline at the end.

Sample

Sample 1
Input
3
1
2
1
Output
T

Sample 2
Input
5
-1
-2
0
1
2
Output
F

It cannot move from -2 to 0 in 1 second.

Sample 3
Input
4
0
1
2
1
Output
F

This is invalid because it did not move from coordinate 0 between time 0 and time 1.

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