結果

問題 No.69 文字を自由に並び替え
ユーザー yun_appyun_app
提出日時 2016-06-11 01:14:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 1,041 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 74,720 KB
実行使用メモリ 49,628 KB
最終ジャッジ日時 2023-08-20 23:23:25
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,528 KB
testcase_01 AC 40 ms
49,276 KB
testcase_02 AC 40 ms
49,352 KB
testcase_03 AC 41 ms
49,312 KB
testcase_04 AC 40 ms
49,308 KB
testcase_05 AC 40 ms
49,244 KB
testcase_06 AC 41 ms
49,472 KB
testcase_07 AC 42 ms
49,116 KB
testcase_08 AC 41 ms
49,512 KB
testcase_09 AC 41 ms
49,184 KB
testcase_10 AC 40 ms
49,444 KB
testcase_11 AC 41 ms
49,104 KB
testcase_12 AC 41 ms
49,084 KB
testcase_13 AC 40 ms
49,444 KB
testcase_14 AC 39 ms
49,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone{
    public static void main(String[] args) throws Exception{
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();
        if(s.length()!=t.length()){
            System.out.println("NO");
            return;
        }
        HashMap<Character,Integer> map = new HashMap<Character,Integer>();
        for(int i=0;i<s.length();i++){
            char c = s.charAt(i);
            map.put(c,map.containsKey(c)?map.get(c)+1:1);
        }
        for(int i=0;i<t.length();i++){
            char c = t.charAt(i);
            if(!map.containsKey(c)){
                System.out.println("NO");
                return;
            }
            int n = map.get(c);
            if(n==0){
                System.out.println("NO");
                return;
            }
            map.put(c,n-1);
        }
        System.out.println("YES");
    }
}

0