結果

問題 No.69 文字を自由に並び替え
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 17:36:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 3,813 ms
コンパイル使用メモリ 74,524 KB
実行使用メモリ 57,832 KB
最終ジャッジ日時 2023-08-20 23:57:52
合計ジャッジ時間 6,291 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,220 KB
testcase_01 AC 112 ms
55,812 KB
testcase_02 AC 113 ms
55,476 KB
testcase_03 AC 112 ms
55,796 KB
testcase_04 AC 113 ms
55,320 KB
testcase_05 AC 112 ms
55,208 KB
testcase_06 AC 113 ms
57,832 KB
testcase_07 AC 112 ms
55,996 KB
testcase_08 AC 112 ms
55,640 KB
testcase_09 AC 112 ms
55,964 KB
testcase_10 AC 113 ms
55,808 KB
testcase_11 AC 113 ms
56,492 KB
testcase_12 AC 114 ms
56,328 KB
testcase_13 AC 113 ms
55,476 KB
testcase_14 AC 114 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No69 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		char a [] = new char[A.length()];
		char b [] = new char[B.length()];
		char x;
		
		for(int i = 0;i < a.length;i++) {
			a[i] = A.charAt(i);
			b[i] = B.charAt(i);
		}
		
		for(int i = 0;i < a.length;i++) {
			for(int j = i + 1;j < a.length;j++) {
				if(a[i] > a[j]) {
					x = a[i];
					a[i] = a[j];
					a[j] = x;
				}
				if(b[i] > b[j]) {
					x = b[i];
					b[i] = b[j];
					b[j] = x;
				}
			}
		}
		
		for(int i = 0;i < a.length;i++) {
			if(a[i] != b[i]) {
				System.out.println("NO");
				break;
			}
			if(i == a.length - 1) {
				System.out.println("YES");
			}
		}
	}
}
0