結果

問題 No.2040 010-1 Deletion
ユーザー milkcoffeemilkcoffee
提出日時 2022-05-16 14:16:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,880 bytes
コンパイル時間 5,417 ms
コンパイル使用メモリ 269,120 KB
実行使用メモリ 15,584 KB
最終ジャッジ日時 2023-10-14 17:49:18
合計ジャッジ時間 10,205 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
15,584 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;

/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>
#define pb push_back
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define endl "\n"

#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvvll vector< vector <vector <vector<ll> > > >
#define vvvll vector< vector< vector<ll> > >
#define vvll vector< vector<ll> >
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template <class T>
using V = vector<T>;

constexpr ll INF = (1ll << 60);
//constexpr ll mod = 1000000007;
constexpr ll mod = 998244353;

constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt(T val)
{
    cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v)
{
    ll vs = v.size();
    rep(i, vs)
    {
        cout << v[i];

        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}


ll N;
map<string,ll> mp;

void dfs(string s){
    if(s.size()>N) return;
    if(s.size()==N){
        mp[s]++;
        return;
    }
    ll m=s.size();
    rep(i,m+1){
        string res="";
        rep(j,i){
            res.pb(s[j]);
        }
        res.pb('0');
        res.pb('1');
        res.pb('0');
        rep_up(j,i,m){
            res.pb(s[j]);
        }
        dfs(res);
    }
    rep(i,m+1){
        string res="";
        rep(j,i){
            res.pb(s[j]);
        }
        res.pb('1');
        rep_up(j,i,m){
            res.pb(s[j]);
        }
        dfs(res);
    }
}

// 愚直全列挙 TLE

void solve(){
    ll n, m, k, cnt = 0, sum = 0, ans = 0;
    cin>>N;
    string s;
    cin>>s;
    dfs("");
    ans=mp.size();
    //pt(ans);
    //return;
    ans=0;
    for(auto e:mp){
        //pt(e.se);
        ll flag=0;
        rep(i,N){
            if(e.fi[i]=='0'&&s[i]=='1') flag=1;
            if(e.fi[i]=='1'&&s[i]=='0') flag=1;
        }
        if(flag==0) ans++;
    }
    pt(ans);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cout << fixed << setprecision(16);
    //ll T;
    //cin>>T;
    //rep(ca,T)
    solve();
}   
0