結果
問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
ユーザー |
![]() |
提出日時 | 2025-10-03 21:57:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 2,259 bytes |
コンパイル時間 | 3,437 ms |
コンパイル使用メモリ | 287,920 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 21:57:12 |
合計ジャッジ時間 | 4,787 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; int64_t K; IN(n, K); string s; IN(s); vector<int64_t> cnt(n + 1); cnt[n] = 1; for (int i : Rev(Rep(0, n))) { if (s[i] != '0') { cnt[i] = cnt[i + 1]; } if (i + 2 <= n && (s[i] == '1' || (s[i] == '2' && s[i + 1] <= '6'))) { cnt[i] += cnt[i + 2]; } SetMin(cnt[i], INF64); } string ans; ans.reserve(n); int i = 0; while (i < n) { assert(K <= cnt[i]); if (s[i] != '0') { if (K <= cnt[i + 1]) { ans += char('a' + (s[i] - '1')); ++i; continue; } else { K -= cnt[i + 1]; } } if (i + 2 <= n && (s[i] == '1' || (s[i] == '2' && s[i + 1] <= '6'))) { assert(K <= cnt[i + 2]); ans += char('a' + stoi(s.substr(i, 2)) - 1); i += 2; } } OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include <bits/stdc++.h> template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>; template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; }) #define Rev views::reverse #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define SetMin(...) LAMBDA2(x, y, y < x && (x = y, 1))(__VA_ARGS__) #define INF64 (INT64_MAX / 2) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1