結果

問題 No.1171 Runs in Subsequences
ユーザー optopt
提出日時 2020-07-15 15:20:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 200,680 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-05-01 17:02:31
合計ジャッジ時間 5,973 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,144 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 29 ms
5,376 KB
testcase_05 AC 56 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 113 ms
5,376 KB
testcase_08 AC 114 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
const int MOD  = int(1e9)+7;


struct mint {
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD) {}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  mint& operator-=(const mint a) { if ((x -= a.x) < 0) x += MOD; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main() {
  const int M = 26;
  string s; cin >> s;
  int n = s.size();

  int N = 1<<n;
  mint ans = 0;
  rep2(S, 1, N) {
    string t;
    rep(i, n) if (S>>i&1) t.push_back(s[i]);
    rep(i, t.size()-1) ans += (t[i] != t[i+1]);
    ans += 1;
  }
  cout << ans << "\n";
  return 0;
}
0