結果
問題 | No.69 文字を自由に並び替え |
ユーザー | taku-tech |
提出日時 | 2021-05-23 02:16:59 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 108 ms / 5,000 ms |
コード長 | 934 bytes |
コンパイル時間 | 3,037 ms |
コンパイル使用メモリ | 75,132 KB |
実行使用メモリ | 53,980 KB |
最終ジャッジ日時 | 2024-04-19 10:10:28 |
合計ジャッジ時間 | 5,297 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 101 ms
52,984 KB |
testcase_01 | AC | 96 ms
52,940 KB |
testcase_02 | AC | 104 ms
52,968 KB |
testcase_03 | AC | 106 ms
53,692 KB |
testcase_04 | AC | 104 ms
53,980 KB |
testcase_05 | AC | 95 ms
52,952 KB |
testcase_06 | AC | 95 ms
52,708 KB |
testcase_07 | AC | 99 ms
52,804 KB |
testcase_08 | AC | 106 ms
53,972 KB |
testcase_09 | AC | 108 ms
53,936 KB |
testcase_10 | AC | 95 ms
52,516 KB |
testcase_11 | AC | 103 ms
53,944 KB |
testcase_12 | AC | 94 ms
52,660 KB |
testcase_13 | AC | 102 ms
52,988 KB |
testcase_14 | AC | 97 ms
52,704 KB |
ソースコード
package change_char; import java.util.Arrays; import java.util.Scanner; public class ChangeChar { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String A = sc.nextLine(); String B = sc.nextLine(); if(checkWord(A, B)) { System.out.println("YES"); } else { System.out.println("NO"); } } private static boolean checkWord(String a, String b) { boolean[] checkChar = new boolean[b.length()]; //bの文字に一致したかをチェックする用の配列 boolean[] checkFlag = new boolean[checkChar.length]; Arrays.fill(checkFlag, true); //Aの文字列から一つずつ文字を取り出して一致するか検査 for(int i = 0; i < a.length(); i++) { for(int j = 0; j < b.length(); j++) { if(a.charAt(i) == b.charAt(j) && !checkChar[j]) { checkChar[j] = true; break; } } } return Arrays.equals(checkChar, checkFlag); } }