結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-10-25 00:04:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,009 bytes
コンパイル時間 4,392 ms
コンパイル使用メモリ 260,580 KB
実行使用メモリ 7,676 KB
最終ジャッジ日時 2023-09-16 01:25:14
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,676 KB
testcase_01 AC 43 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define repk(i, k, n) for (int i = k; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define mod1 1000000007
#define mod2 998244353
#define mod3 100000007
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vvl vector<vector<ll>>
#define vvvi vector<vector<vector<int>>>
#define vvvl vector<vector<vector<ll>>>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vvpii vector<vector<pair<int,int>>>
#define vvpll vector<vector<pair<ll,ll>>>

template<typename T> void debug(T e){
    cerr << e << endl;
}

template<typename T> void debug(vector<T> &v){
    rep(i, v.size()){
        cerr << v[i] << " ";
    }
    cerr << endl;
}

template<typename T> void debug(vector<vector<T>> &v){
    rep(i, v.size()){
        rep(j, v[i].size()){
            cerr << v[i][j] << " ";
        }
        cerr << endl;
    }
}

template<typename T> void debug(vector<pair<T, T>> &v){
    rep(i,v.size()){
        cerr << v[i].first << " " << v[i].second << endl;
    }
}

template<typename T> void debug(set<T> &st){
    for (auto itr = st.begin(); itr != st.end(); itr++){
        cerr << *itr << " ";
    }
    cerr << endl;
}

template<typename T> void debug(multiset<T> &ms){
    for (auto itr = ms.begin(); itr != ms.end(); itr++){
        cerr << *itr << " ";
    }
    cerr << endl;
}

template<typename T> void debug(map<T, T> &mp){
    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        cerr << itr->first << " " << itr->second << endl;
    }
}

void debug_out(){
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
    cerr << H << " ";
    debug_out(T...);
}

vector<ll> bitconversion(ll i, ll n, ll N)
{
    ll x = 1;
    rep(j, N)
    {
        x *= n;
    }
    vector<ll> vec(N);
    rep(j, N)
    {
        x /= n;
        vec[j] = i / x;
        i -= x * vec[j];
    }
    return vec;
}

int main(){
    ll N;
    cin >> N;
    ll num = 1;
    for (ll i = 0; i < N; i++){
        num *= 26;
    }

    ll ans = 0;

    for (ll i = 0; i < num; i++){
        vector<ll> bin = bitconversion(i, 26, N);
        string S = "";
        for (ll j = 0; j < N; j++){
            S += (char)(bin[j] + 'a');
        }
        ll state = 0;
        ll cnt = 0;
        for (ll j = 0; j < N; j++){
            if (state == 0 && S[j] == 'c') state = 1;
            else if (state == 1 && S[j] == 'o') state = 2;
            else if (state == 2 && S[j] == 'n'){
                state = 0;
                cnt++;
            }
        }
        ans += cnt;
    }
    cout << ans << endl;
}
0