結果

問題 No.69 文字を自由に並び替え
ユーザー jimanojimano
提出日時 2016-06-19 21:04:53
言語 Java19
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 900 bytes
コンパイル時間 3,312 ms
コンパイル使用メモリ 72,560 KB
実行使用メモリ 49,860 KB
最終ジャッジ日時 2023-08-20 23:23:31
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,428 KB
testcase_01 AC 42 ms
49,320 KB
testcase_02 AC 42 ms
49,420 KB
testcase_03 AC 42 ms
49,860 KB
testcase_04 AC 41 ms
49,528 KB
testcase_05 AC 41 ms
49,320 KB
testcase_06 AC 41 ms
49,544 KB
testcase_07 AC 40 ms
49,440 KB
testcase_08 AC 42 ms
49,348 KB
testcase_09 AC 40 ms
49,368 KB
testcase_10 AC 43 ms
49,368 KB
testcase_11 AC 41 ms
49,464 KB
testcase_12 AC 41 ms
49,768 KB
testcase_13 AC 41 ms
49,328 KB
testcase_14 AC 44 ms
49,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	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