結果

問題 No.69 文字を自由に並び替え
ユーザー jimanojimano
提出日時 2016-06-19 21:06:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 3,122 ms
コンパイル使用メモリ 74,344 KB
実行使用メモリ 37,268 KB
最終ジャッジ日時 2024-05-08 05:10:55
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,080 KB
testcase_01 AC 53 ms
37,204 KB
testcase_02 AC 52 ms
37,200 KB
testcase_03 AC 52 ms
37,112 KB
testcase_04 AC 51 ms
36,916 KB
testcase_05 AC 53 ms
37,112 KB
testcase_06 AC 51 ms
36,800 KB
testcase_07 AC 50 ms
36,808 KB
testcase_08 AC 49 ms
36,808 KB
testcase_09 AC 48 ms
37,204 KB
testcase_10 AC 48 ms
37,224 KB
testcase_11 AC 49 ms
37,268 KB
testcase_12 AC 49 ms
36,988 KB
testcase_13 AC 51 ms
36,872 KB
testcase_14 AC 49 ms
37,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No0068 {
	public static void main(String[] args) {
		try (BufferedReader br = 
				new BufferedReader(new InputStreamReader(System.in))) {
			// char→intに変換し、ソートと比較を行う
			char[] a = br.readLine().toCharArray();
			char[] b = br.readLine().toCharArray();
			int[] aCode = toCode(a);
			int[] bCode = toCode(b);

			Arrays.sort(aCode);
			Arrays.sort(bCode);

			for (int i = 0; i < aCode.length; i++) {
				if (aCode[i] != bCode[i]) {
					System.out.println("NO");
					return;
				}
			}
			System.out.println("YES");

		} catch (IOException e) {
			e.printStackTrace();
		}
    }
	
	static int[] toCode(char[] chr){
		int[] code = new int[chr.length];
		for(int i =0; i < chr.length; i++){
			code[i] = (int)chr[i];
		}
		return code;
	}
}
0