結果
問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
ユーザー |
![]() |
提出日時 | 2025-10-04 18:02:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,176 bytes |
コンパイル時間 | 5,352 ms |
コンパイル使用メモリ | 334,908 KB |
実行使用メモリ | 43,952 KB |
最終ジャッジ日時 | 2025-10-04 18:02:14 |
合計ジャッジ時間 | 10,308 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 1 WA * 26 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #include<functional> using namespace std; using ll = long long; int main() { ll N, K; cin >> N >> K; string t; cin >> t; // DP[i番目] := i〜endのパターン数 vector<ll> DP(N, -1); function<ll(int)> dfs = [&](int n) { if (-1<DP[n]) return DP[n]; if (N-2<=n) { DP[n] = 1; return 1LL; } string s2 = t.substr(n, 2); int d2 = stoi(s2); ll res = 0LL; if (d2<=26) { res += dfs(n+1); } res += dfs(n+2); return DP[n] = res; }; dfs(0); string res = ""; ll count = 0; for (int i=0;i<N;) { string s2 = t.substr(i, 2); int d1 = stoi(t.substr(i, 1)); int d2 = stoi(s2); if (d2<=26) { if (count+DP[i+1]<K) { res += 'a' + (d2-1); count += DP[i+1]; i +=2; } else { res += 'a' + (d1-1); i++; } } else { res += 'a' + (d1-1); i++; } } cout << res << endl; }