結果
問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
ユーザー |
|
提出日時 | 2025-09-15 16:57:14 |
言語 | C# (.NET 8.0.404) |
結果 |
RE
|
実行時間 | - |
コード長 | 991 bytes |
コンパイル時間 | 8,336 ms |
コンパイル使用メモリ | 170,616 KB |
実行使用メモリ | 201,800 KB |
最終ジャッジ日時 | 2025-09-15 16:57:29 |
合計ジャッジ時間 | 15,677 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 RE * 12 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (113 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
#nullable enable int n; long k; { var input = Console.ReadLine()!.Split(' '); n = int.Parse(input[0]); k = int.Parse(input[1]); } var s = Console.ReadLine()!; var f = new long[n]; f.AsSpan().Fill(-1); int C(int j, int l) { var c1 = s[j] - '0'; if (c1 == 0) return -1; if (l == 1) return c1; if (c1 >= 3 || j + 1 >= n) return -1; var c2 = c1 * 10 + s[j + 1] - '0'; if (c2 > 26) return -1; return c2; } long F(int j) { if (j == n) return 1; if (f[j] >= 0) return f[j]; var res = 0L; if (C(j, 1) >= 0) res += F(j + 1); if (C(j, 2) >= 0) res += F(j + 2); if (res > k) res = k + 1; return f[j] = res; } var ans = new List<int>(); var j = 0; var l = 0L; while (j < n) { var c1 = C(j, 1); var f1 = F(j + 1); if (l + f1 >= k) { j++; ans.Add(c1); continue; } l += f1; ans.Add(C(j, 2)); j += 2; } Console.WriteLine(new string(ans.Select(e => (char)(e - 1 + 'a')).ToArray()));