結果

問題 No.52 よくある文字列の問題
ユーザー sansaquasansaqua
提出日時 2019-08-06 03:07:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,324 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 78,080 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 17:37:03
合計ジャッジ時間 1,419 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <list>

using namespace std;
using ll = long long int;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#define ALL_INCLUDED_ENVIRONMENT

template <class T> std::ostream& operator<<(std::ostream& o, const std::vector<T>& v) {
  o << "{";
  for (int i = 0; i < (int) v.size(); i++)
    o << (i > 0 ? ", " : "" ) << v[i];
  o << "}";
  return o;
}

template <class T> std::ostream& operator<<(std::ostream& o, const std::list<T>& lst) {
  o << "{";
  for (auto itr = lst.begin(); itr != lst.end(); itr++)
    o << (itr == lst.begin() ? "" : ", " ) << *itr;
  o << "}";
  return o;
}

template <class X, class Y> std::ostream& operator<<(std::ostream& o, const std::pair<X, Y>& p) {
  o << "(" << p.first << ", " << p.second << ")";
  return o;
}

int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  string s;
  cin >> s;
  set<string> table;
  
  int n = s.size();
  string key(n, ' ');
  REP(bits, 1 << n) {
    string::iterator l = s.begin();
    string::iterator r = s.end(); r--;
    REP(i, n) {
      if (bits & (1 << i)) {
        key[i] = *l;
        l++;
      } else {
        key[i] = *r;
        r--;
      }
    }
    // cout << lst << "\n";
    table.insert(key);
  }
  cout << table.size() << "\n";
  return 0;
}
0