結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 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<list<char> > table;
  
  int n = s.size();
  REP(bits, 1 << n) {
    list<char> lst;
    string::iterator l = s.begin();
    string::iterator r = s.end(); r--;
    REP(i, n) {
      if (bits & (1 << i)) {
        lst.push_back(*l);
        l++;
      } else {
        lst.push_back(*r);
        r--;
      }
    }
    // cout << lst << "\n";
    table.insert(lst);
  }
  cout << table.size() << "\n";
  return 0;
}
0