結果
問題 |
No.52 よくある文字列の問題
|
ユーザー |
|
提出日時 | 2017-01-19 11:02:05 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 741 ms |
コンパイル使用メモリ | 95,652 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 06:29:14 |
合計ジャッジ時間 | 1,290 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; bool[string] buf; auto n = s.length; auto t = new char[](n); foreach (j; (1 << n).iota) { auto u = s.dup; foreach (i; n.iota) { if (bitTest(j, i)) { t[i] = u[0]; u = u[1..$]; } else { t[i] = u[$-1]; u = u[0..$-1]; } } buf[t.to!string] = true; } writeln(buf.length); } bool bitTest(T)(T n, size_t i) { return (n & (1.to!T << i)) != 0; }