問題一覧 > 通常問題

No.239 Nyanpass

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

Problem Statement

It is said that Renge Miyauchi (commonly known as Renchon) greets people with "nyanpass" at any time and on any occasion.
By extension, a person who greets with "nyanpass" at any time and on any occasion is called "Renchon-like".

There are $N$ villagers in the village, assigned villager numbers \(1 ~ N\).
The greeting history of the $N$ people is given as an $N \times N$ matrix $A$. $A_{ij}$ represents what villager $j$ said when villagers $i$ and $j$ greeted each other.

When exactly one person among the $N$ people is Renchon-like, we say that Renchon has been "identified".
If Renchon can be identified, output that villager number; otherwise, output -1.

Input

$N$
$A_{11}$ $A_{12}$ $\ldots$ $A_{1N}$
$A_{21}$ $A_{22}$ $\ldots$ $A_{2N}$
$\ldots$
$A_{N1}$ $A_{N2}$ $\ldots$ $A_{NN}$
  • $2 \leq N \leq 100$
  • $A_{ii}$ is "-" (excluding the quotation marks)
  • $A_{ij}$ is a string of between 1 and 30 lowercase English letters.

Output

If Renchon can be identified, output that villager number; otherwise, output -1.

Sample

Sample 1
Input
4
- nyanpass uissu ohayo
konbanwa - ohayo ohayo
ohayogozaimasu nyanpass - komachanyuuna
konnichiwa nyanpass komachanohayo -
Output
2
Sample 2
Input
3
- nyanpass ohayo
nyanpass - chicchakunaiyo
nyanpass nyanpass -
Output
-1

Villagers 1 and 2 are Renchon-like, so the answer is -1.

Sample 3
Input
3
- ohayo nyanpass
nyanpass - ohayo
nyanpass ohayo -
Output
1

People other than Renchon might say "nyanpass" now and then, too.

Sample 4
Input
2
- ohayo
zukoo -
Output
-1

No Renchon here...

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