問題一覧 > 通常問題

No.632 Fill-in-the-Blank Kadomatsu Sequence

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

Definition

It is said that a sequence $v = (a_1,a_2,a_3)$ of three natural numbers, $v$, is a Kadomatsu sequence when it satisfies the following conditions.

  1. $a_1,a_2,a_3$ are all distinct
  2. Among the three elements, $a_2$ is the largest or the smallest


Problem Statement

One day, Yukikoji found cards with the characters "?", "2", and "3" written on them, placed in a row on a table.

Yukikoji has cards with the characters "1" and "4" written on them,
and plans to turn the sequence of numbers on the table into a Kadomatsu sequence by replacing the "?" on the table with one of these cards.

Which of the cards "1" and "4" can replace the "?"?

Input

$c_1$ $c_2$ $c_3$

Three space-separated characters are given from standard input.
Each of the three characters is one of '2', '3', or '?'.
No character is given more than once.
That is, you do not need to consider inputs such as "2 ? ?", "2 3 3", or "4 2 ?".

This input means that the cards are arranged on the table in the order $c_1$ $c_2$ $c_3$.

Output

If the card that should replace the "?" is "1", output '1'; if it is "4", output '4'.
If either "1" or "4" works, output '14'.

Print a newline at the end.

Sample

Sample 1
Input
? 2 3
Output
4

Replacing '?' with '4' gives $(4,2,3)$, which makes a Kadomatsu sequence.

Sample 2
Input
3 ? 2
Output
14

Replacing '?' with '1' gives $(3,1,2)$, which makes a Kadomatsu sequence.
In addition, replacing '?' with '4' gives $(3,4,2)$, which also makes a Kadomatsu sequence, so you must output 14.

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