結果

問題 No.295 hel__world
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-14 12:52:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,594 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 208,136 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-09 18:12:41
合計ジャッジ時間 9,888 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 TLE -
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 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/295/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    vector<ll> S(26);
    string T;
    for (auto&& s : S) {
        cin >> s;
    }
    cin >> T;
    vector<vector<ll>> cnt(26);
    char c = '-';
    int len = 0;
    for (int i = 0; i < T.size(); i++) {
        char& t = T[i];
        if (t != c) {
            if (c != '_') {
                cnt[c - 'a'].emplace_back(len);
            }
            c = t;
            len = 0;
        }
        len++;
    }
    if (len)
        cnt[c - 'a'].emplace_back(len);
    ll ans = 1;
    for (int i = 0; i < 26; i++) {
        priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, function<bool(const pair<ll, ll>& x, const pair<ll, ll>& y)>> que([](const pair<ll, ll>& x, const pair<ll, ll>& y) {
            return __int128(x.first + 1) * (y.first - y.second + 1) < __int128(y.first + 1) * (x.first - x.second + 1);
        });
        for (auto&& x : cnt[i]) {
            S[i] -= x;
            que.push({x, x});
        }
        if (S[i] < 0) {
            cout << 0 << endl;
            return 0;
        }
        if (cnt[i].size() == 0)
            continue;
        while (S[i]--) {
            auto [maine, book] = que.top();
            que.pop();
            ans /= (maine - book + 1);
            if (__int128(ans) * (maine + 1) < (1ll << 62))
                ans *= (maine + 1);
            else {
                cout << "hel" << endl;
                return 0;
            }
            que.push({maine + 1, book});
        }
    }
    cout << ans << endl;
}
0