結果

問題 No.239 にゃんぱすー
ユーザー mitsuo
提出日時 2016-05-05 12:12:29
言語 Java
(openjdk 23)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 78,232 KB
実行使用メモリ 57,000 KB
最終ジャッジ日時 2024-10-05 09:33:58
合計ジャッジ時間 8,303 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> input = new ArrayList<>();
		while (sc.hasNext()) {
			input.add(sc.nextLine());
		}

		System.out.println(solve(input));

		sc.close();
	}

	public static int solve(List<String> in) {
		int N = Integer.valueOf(in.get(0));
		in.remove(0);
		List<String> cand = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			cand.add(String.valueOf(i));
		}

		for (int i = 0; i < N; i++) {
			String[] s = in.get(i).split(" ");
			for (int j = 0; j < N; j++) {
				if (!s[j].equals("nyanpass") && !s[j].equals("-")) {
					cand.remove(String.valueOf(j));
				}

			}
		}

		if (cand.size() == 1) {
			return Integer.valueOf(cand.get(0)) + 1;
		} else {
			return -1;
		}

	}

}
0