結果
問題 | No.295 hel__world |
ユーザー |
![]() |
提出日時 | 2021-05-14 12:52:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,594 bytes |
コンパイル時間 | 2,218 ms |
コンパイル使用メモリ | 208,124 KB |
最終ジャッジ日時 | 2025-01-21 10:52:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 4 RE * 7 TLE * 11 |
ソースコード
//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; }