結果
問題 | No.52 よくある文字列の問題 |
ユーザー |
|
提出日時 | 2025-03-30 15:11:55 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 697 bytes |
コンパイル時間 | 5,747 ms |
コンパイル使用メモリ | 221,496 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-30 15:12:02 |
合計ジャッジ時間 | 6,737 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
module main;// https://yamakasa3.hatenablog.com/entry/2018/06/24/214358 よりimport std;bool[] bit;dchar[][] a;RedBlackTree!(dchar[]) set;int n;void solve(){int l = 0, r = n - 1;auto t = new dchar[][](n);foreach (i; 0 .. n) {if (!bit[i]) {t[i] = a[l];l++;} else {t[i] = a[r];r--;}}set.insert(t.joiner.array);}void rec(int k){if (k == n) {solve();return;}rec(k + 1);bit[k] = true;rec(k + 1);bit[k] = false;}void main(){// 入力auto s = readln.chomp;a = s.map!(a => [a]).array;n = s.length.to!int;bit = new bool[](n);set = new RedBlackTree!(dchar[])();// 答えの計算と出力rec(0);writeln(set.length);}