結果

問題 No.69 文字を自由に並び替え
ユーザー GchansanjouGchansanjou
提出日時 2018-02-11 22:31:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,039 bytes
コンパイル時間 3,192 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 51,448 KB
最終ジャッジ日時 2023-09-09 21:24:24
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,288 KB
testcase_01 AC 41 ms
49,300 KB
testcase_02 AC 42 ms
49,072 KB
testcase_03 AC 41 ms
49,492 KB
testcase_04 AC 43 ms
49,300 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 42 ms
49,308 KB
testcase_09 AC 42 ms
49,116 KB
testcase_10 AC 42 ms
49,200 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 41 ms
49,204 KB
testcase_14 AC 42 ms
49,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukiCoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No00069 {

	public static void main(String[] args) {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input1 = bufferedReader.readLine();
			String input2 = bufferedReader.readLine();

			System.out.println(isEqual(input1, input2) ? "YES" : "NO");

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static Boolean isEqual(String input1 , String input2) {
		String[] indexArray = new String[input1.length()];
		for(int i = 0; i < input2.length() ; i++) {
			String digit = String.valueOf(input2.charAt(i));
			int index = input1.indexOf(digit);
			if (index != -1) {
				if(indexArray[index] == null) indexArray[index] = digit;
			}
		}
		StringBuilder builder = new StringBuilder();
		for (int i = 0 ; i < indexArray.length ; i++) {
			builder.append(indexArray[i]);
		}
		return input1.equals(builder.toString()) ? true : false;
	}

}
0