結果

問題 No.69 文字を自由に並び替え
ユーザー tsunabittsunabit
提出日時 2018-04-22 04:20:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,554 bytes
コンパイル時間 4,642 ms
コンパイル使用メモリ 74,488 KB
実行使用メモリ 58,592 KB
最終ジャッジ日時 2023-09-09 21:29:44
合計ジャッジ時間 6,239 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

// ***問題文***
// 同じ長さの文字列Aと文字列Bが与えられる。
// 文字列Aの順番を自由に並び替えることができる。
// 文字列Aと文字列Bを同じにできるか判定せよ。
// ***入力***
// A
// B
// 文字列Aと文字列Bは1文字以上10文字以内の文字列。
// 文字列Aの長さと文字列Bの長さはかならず同じ。
// 文字はすべて小文字のアルファベットaからzで構成される。
// ***出力***
// 可能ならYES、不可能ならNOを出力せよ。
// 改行を忘れずに。

public class No69 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();

        String[] AA = A.split("",0);
        String[] BB = B.split("",0);

        ArrayList<String> aal = new ArrayList<String>(Arrays.asList(AA));
        Collections.sort(aal);
        ArrayList<String> bbl = new ArrayList<String>(Arrays.asList(BB));
        Collections.sort(bbl);

        boolean flag = true;
        for(int i = 0; i < aal.size(); i++) {
            if(!(aal.get(i).equals(bbl.get(i)))) {
                flag = false;
            }
        }
        
        if(flag == true) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}
0