結果

問題 No.3290 Encrypt Failed, but Decrypt Succeeded
ユーザー ルビサファせだい
提出日時 2025-10-03 21:50:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,525 bytes
コンパイル時間 3,186 ms
コンパイル使用メモリ 286,484 KB
実行使用メモリ 12,704 KB
最終ジャッジ日時 2025-10-03 21:51:14
合計ジャッジ時間 7,117 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 3 WA * 2 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/fenwicktree.hpp>
#include <atcoder/segtree.hpp>
#include <atcoder/modint.hpp>
#include <atcoder/dsu.hpp>
#include <atcoder/lazysegtree.hpp>

using namespace atcoder;
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<>>;
ll ll_min = numeric_limits<ll>::min();
ll ll_max = numeric_limits<ll>::max();
ll ALPHABET_N = 26;
using mint = modint998244353;
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define rep_(i, k, n) for (ll i = (ll)k; i < (ll)n; i++)
#define all(a) a.begin(), a.end()

char num_str_to_char(string num)
{
	return (char)(stoi(num) + 'a' - 1);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	ll cnt = 0;
	string t;
	string ans;
	auto dfs = [&](auto &f, ll i) -> void
	{
		if (i == n)
		{
			cnt++;
			if (cnt == k)
			{
				ans = t;
			}
			return;
		}
		t += num_str_to_char(string(1, s[i]));
		f(f, i + 1);
		t.pop_back();
		if (i < n - 1)
		{
			if (s[i] == '1')
			{
				string num = string(1, s[i]) + string(1, s[i + 1]);
				t += num_str_to_char(num);
				f(f, i + 2);
				t.pop_back();
			}
			if (s[i] == '2')
			{
				if (s[i + 1] <= '7')
				{
					string num = string(1, s[i]) + string(1, s[i + 1]);
					t += num_str_to_char(num);
					f(f, i + 2);
					t.pop_back();
				}
			}
		}
	};
	dfs(dfs, 0);
	cout << ans << endl;
	return 0;
}
0