結果
問題 | No.170 スワップ文字列(Easy) |
ユーザー | tenten |
提出日時 | 2022-07-29 10:09:06 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 115 ms / 5,000 ms |
コード長 | 1,549 bytes |
コンパイル時間 | 2,250 ms |
コンパイル使用メモリ | 74,560 KB |
実行使用メモリ | 58,144 KB |
最終ジャッジ日時 | 2023-09-26 06:24:06 |
合計ジャッジ時間 | 5,613 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,424 KB |
testcase_01 | AC | 115 ms
57,860 KB |
testcase_02 | AC | 87 ms
54,888 KB |
testcase_03 | AC | 91 ms
54,868 KB |
testcase_04 | AC | 90 ms
55,328 KB |
testcase_05 | AC | 111 ms
58,076 KB |
testcase_06 | AC | 114 ms
58,144 KB |
testcase_07 | AC | 62 ms
52,368 KB |
testcase_08 | AC | 90 ms
55,784 KB |
testcase_09 | AC | 88 ms
55,160 KB |
testcase_10 | AC | 95 ms
55,032 KB |
testcase_11 | AC | 45 ms
49,340 KB |
testcase_12 | AC | 44 ms
49,384 KB |
testcase_13 | AC | 44 ms
49,248 KB |
testcase_14 | AC | 44 ms
49,296 KB |
testcase_15 | AC | 49 ms
50,348 KB |
testcase_16 | AC | 46 ms
49,464 KB |
testcase_17 | AC | 45 ms
49,416 KB |
testcase_18 | AC | 46 ms
49,376 KB |
testcase_19 | AC | 45 ms
49,324 KB |
testcase_20 | AC | 44 ms
49,328 KB |
testcase_21 | AC | 49 ms
50,152 KB |
testcase_22 | AC | 45 ms
49,348 KB |
testcase_23 | AC | 45 ms
49,356 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static HashSet<String> strings = new HashSet<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] input = sc.next().toCharArray(); search(0, input, new char[input.length], new boolean[input.length]); System.out.println(strings.size() - 1); } static void search(int idx, char[] input, char[] output, boolean[] used) { if (idx >= input.length) { strings.add(new String(output)); return; } for (int i = 0; i < input.length; i++) { if (used[i]) { continue; } used[i] = true; output[idx] = input[i]; search(idx + 1, input, output, used); used[i] = false; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }