結果
問題 | No.239 にゃんぱすー |
ユーザー |
![]() |
提出日時 | 2015-10-02 11:58:52 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 74,996 KB |
実行使用メモリ | 46,428 KB |
最終ジャッジ日時 | 2024-07-19 19:06:06 |
合計ジャッジ時間 | 9,253 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
import java.util.Scanner;import java.util.ArrayList;class solve {public static void main(String args[]) {Scanner scan = new Scanner(System.in);int n = scan.nextInt();String a[][] = new String[n][n];for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {a[i][j] = scan.next();}}ArrayList<Integer> ans = new ArrayList<Integer>();for (int i = 0; i < n; i++) {boolean ok = true;for (int j = 0; j < n; j++) {if (i == j) continue;if (!a[j][i].equals("nyanpass")) {ok = false;break;}}if (ok) {ans.add(i+1);}}if (ans.size() == 1) {System.out.println(ans.get(0));}else {System.out.println("-1");}}}