結果

問題 No.239 にゃんぱすー
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-14 13:24:19
言語 Java
(openjdk 23)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 46,828 KB
最終ジャッジ日時 2024-11-17 14:25:41
合計ジャッジ時間 10,570 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[][] a = new String[n][n];
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < n ; j++) {
				a[i][j] = sc.next();
			}
		}
		int ret = 0; int cnt1 = 0;
		for(int i = 0 ; i < n ; i++) {
			int cnt = 0;
			for(int j = 0 ; j < n ; j++) {
				if(a[j][i].equals("nyanpass")) {
					cnt++;
				}
				if(cnt == n - 1) {
					cnt1++;
					ret = i + 1;
					break;
				}
			}
		}
		if(cnt1 == 1) {
			System.out.println(ret);
		} else {
			System.out.println(-1);
		}
 	}
}
0