提出詳細


ソースコード

import java.io.*;
import java.util.*;

class TeraCoderK {
	BufferedReader in;

	TeraCoderK() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}

	void run() {
		int[] values;

		values = readIntTokens();
		int numCases = values[0];

		for (int i = 1; i <= numCases; i++) {
			values = readIntTokens();
			int[] starts = new int[26];
			int[] ends = new int[26];
			for (int j = 0; j < values[0]; j++) {
				try {
					String word = in.readLine();
					starts[word.charAt(0) - 'a']++;
					ends[word.charAt(word.length() - 1) - 'a']++;
				} catch (IOException ioe) {
					return;
				}
			}

			System.out.println("Case #" + i + ":");
			boolean ng = false;
			for (int j = 0; j < 26; j++) {
				if (starts[j] != ends[j]) {
					System.out.println("NG");
					ng = true;
					break;
				}
			}
			if (!ng)  System.out.println("OK");
		}

		close();
	}

	int getMax(int val) {
		ArrayList<Integer> digits = new ArrayList<Integer>();
		for (int i = 0; i < 4; i++) {
			digits.add(val % 10);
			val /= 10;
		}
		Collections.sort(digits);
		int max = 0;
		for (int i = 3; i >= 0; i--) {
			max += digits.get(i);
			max *= 10;
		}
		max /= 10;
		return max;
	}

	int getMin(int val) {
		ArrayList<Integer> digits = new ArrayList<Integer>();
		for (int i = 0; i < 4; i++) {
			digits.add(val % 10);
			val /= 10;
		}
		Collections.sort(digits);
		int max = 0;
		for (int i = 0; i < 4; i++) {
			max += digits.get(i);
			max *= 10;
		}
		max /= 10;
		return max;
	}

	public static void main(String[] args) {
		TeraCoderK app = new TeraCoderK();
		app.run();
	}

	int[] readIntTokens() {
		String str;
		int[] intTokens;

		try {
			str = in.readLine();
			if (str == null || str.equals(""))  return null;
		} catch (IOException ioe) {
			// ioe.printStackTrace();
			return null;
		}

		String[] tokens = str.split(" ");
		intTokens = new int[tokens.length];
		for (int i = 0; i < tokens.length; i++) {
			intTokens[i] = Integer.parseInt(tokens[i]);
		}
		return intTokens;
	}

	void close() {
		try {
			in.close();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}
}

提出情報

提出時間 2019-11-30 17:11:44
問題 K - ワードサークル
ユーザ名 neco3
状態 不正解
正解率 48/50
提出出力結果

テストケース情報

# 状態 詳細情報
テストケース 1 正解 詳細を見る
テストケース 2 正解 詳細を見る
テストケース 3 正解 詳細を見る
テストケース 4 正解 詳細を見る
テストケース 5 不正解 詳細を見る
テストケース 6 正解 詳細を見る
テストケース 7 正解 詳細を見る
テストケース 8 正解 詳細を見る
テストケース 9 正解 詳細を見る
テストケース 10 正解 詳細を見る
テストケース 11 正解 詳細を見る
テストケース 12 正解 詳細を見る
テストケース 13 正解 詳細を見る
テストケース 14 正解 詳細を見る
テストケース 15 正解 詳細を見る
テストケース 16 正解 詳細を見る
テストケース 17 正解 詳細を見る
テストケース 18 正解 詳細を見る
テストケース 19 正解 詳細を見る
テストケース 20 正解 詳細を見る
テストケース 21 正解 詳細を見る
テストケース 22 正解 詳細を見る
テストケース 23 正解 詳細を見る
テストケース 24 正解 詳細を見る
テストケース 25 正解 詳細を見る
テストケース 26 正解 詳細を見る
テストケース 27 正解 詳細を見る
テストケース 28 正解 詳細を見る
テストケース 29 正解 詳細を見る
テストケース 30 正解 詳細を見る
テストケース 31 正解 詳細を見る
テストケース 32 正解 詳細を見る
テストケース 33 正解 詳細を見る
テストケース 34 正解 詳細を見る
テストケース 35 正解 詳細を見る
テストケース 36 正解 詳細を見る
テストケース 37 正解 詳細を見る
テストケース 38 正解 詳細を見る
テストケース 39 正解 詳細を見る
テストケース 40 正解 詳細を見る
テストケース 41 正解 詳細を見る
テストケース 42 正解 詳細を見る
テストケース 43 正解 詳細を見る
テストケース 44 正解 詳細を見る
テストケース 45 正解 詳細を見る
テストケース 46 正解 詳細を見る
テストケース 47 正解 詳細を見る
テストケース 48 正解 詳細を見る
テストケース 49 正解 詳細を見る
テストケース 50 不正解 詳細を見る