結果

問題 No.69 文字を自由に並び替え
ユーザー mustonmuston
提出日時 2016-06-01 09:06:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 850 bytes
コンパイル時間 3,351 ms
コンパイル使用メモリ 72,460 KB
実行使用メモリ 56,144 KB
最終ジャッジ日時 2023-08-20 23:20:41
合計ジャッジ時間 5,826 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,908 KB
testcase_01 AC 117 ms
55,868 KB
testcase_02 AC 118 ms
55,436 KB
testcase_03 AC 114 ms
55,816 KB
testcase_04 AC 115 ms
55,960 KB
testcase_05 AC 116 ms
56,008 KB
testcase_06 AC 114 ms
55,716 KB
testcase_07 AC 118 ms
56,144 KB
testcase_08 AC 115 ms
55,412 KB
testcase_09 AC 117 ms
55,444 KB
testcase_10 AC 114 ms
55,792 KB
testcase_11 AC 116 ms
56,108 KB
testcase_12 AC 116 ms
55,580 KB
testcase_13 AC 116 ms
55,644 KB
testcase_14 AC 117 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
/*No.69*/
public class No69 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//文字列Aを入力
		char[] a = scan.next().toCharArray();
		//文字列Bを入力
		char[] b = scan.next().toCharArray();
		//配列を文字コードに変換
		int[] aCord = new int[a.length];
		int[] bCord = new int[b.length];
		boolean canSwap = true;
		for(int i=0;i<a.length;i++){
			 aCord[i] = (int)a[i];
			 bCord[i] = (int)b[i];
		}
		//AとBを並び替え
		Arrays.sort(aCord);
		Arrays.sort(bCord);
		//一文字ずつ比較
		for(int i=0;i<aCord.length;i++){
			if(aCord[i]!=bCord[i]){
				canSwap = false;
				break;
			}
		}
		//入れ替えても同じかどうか出力
		if(canSwap){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}
0