問題一覧 > 通常問題

No.197 Magic Trick

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

Problem Statement

A-kun is practicing a magic trick. The trick goes as follows.

Three hats are lined up, each of which either contains one coin or contains no coin.
First, A-kun shows for every hat whether it contains a coin or not.
One operation swaps either the left two hats or the right two hats, along with their contents.
A-kun asks a customer to perform exactly $N$ operations in any way they like.
(The number of operations is known, but how they were performed cannot be seen.)
If the state is impossible when A-kun opens all the hats, the trick is a success.

Tell A-kun "SUCCESS" if his trick succeeded, and "FAILURE" if it failed.

Input

$S_{before}$
$N$
$S_{after}$

$S_{before}$ is a string of 3 characters, each of which is 'o' or 'x'.
$S_{before}$ represents, in order from the left hat, whether each hat initially contains a coin or not.
'o' means the hat contains a coin. 'x' means the hat does not contain a coin.
$N$ is the number of operations the customer performs. $0 \le N \le 2000000000$.
$S_{after}$ is a string of 3 characters, each of which is 'o' or 'x'.
$S_{after}$ represents, in order from the left hat, whether each hat contains a coin or not after the $N$ operations.
'o' means the hat contains a coin. 'x' means the hat does not contain a coin.

Output

Print "SUCCESS" if A-kun's trick is a success, or "FAILURE" if it is a failure, on one line.
Do not forget the newline at the end.

Sample

Sample 1
Input
xxo
1
oxx
Output
SUCCESS

There are three hats.
The rightmost hat contains a coin.
After one operation, the coin has moved to the leftmost hat.
Neither swapping the left two hats nor swapping the right two hats produces this state.
Since this is impossible, A-kun's trick is a success.

Sample 2
Input
xoo
2
oox
Output
FAILURE

There are three hats.
The middle hat and the rightmost hat contain coins.
After two operations, the coins have moved to the middle hat and the leftmost hat.
This state is possible by first swapping the left two hats and then swapping the right two hats.
Therefore, there is nothing mysterious about it, and A-kun's trick is a failure.

Sample 3
Input
ooo
0
xxx
Output
SUCCESS

By performing 0 operations (that is, doing nothing), all the coins in the hats have disappeared.
The trick is a success.

Sample 4
Input
oxo
2000000000
oxo
Output
FAILURE

This is possible. It is a failure.

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