結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
36,800 KB
testcase_01 AC 49 ms
36,672 KB
testcase_02 AC 50 ms
36,876 KB
testcase_03 AC 50 ms
37,260 KB
testcase_04 AC 50 ms
36,800 KB
testcase_05 AC 51 ms
36,968 KB
testcase_06 AC 51 ms
36,984 KB
testcase_07 AC 47 ms
37,076 KB
testcase_08 AC 49 ms
36,948 KB
testcase_09 AC 50 ms
36,872 KB
testcase_10 AC 49 ms
37,112 KB
testcase_11 AC 51 ms
36,992 KB
testcase_12 AC 49 ms
36,948 KB
testcase_13 AC 49 ms
36,992 KB
testcase_14 AC 50 ms
36,808 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);

			if(Arrays.equals(aCode,bCode)){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		} 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