結果

問題 No.3290 Encrypt Failed, but Decrypt Succeeded
ユーザー neet
提出日時 2025-10-03 22:10:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,289 bytes
コンパイル時間 3,166 ms
コンパイル使用メモリ 278,760 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-03 22:10:53
合計ジャッジ時間 5,548 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #include<atcoder/all>
// using mint = atcoder::modint998244353;
using ld = long double;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename T>bool chmin(T&a,T b){return b<a?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return b>a?(a=b,1):0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    long N,K;
    cin>>N>>K;
    string T;
    cin>>T;
    auto f=[&](int i)->bool {
        if(i>=N-1) return 0;
        char a=T[i];
        char b=T[i+1];
        return (a!='0'&&(a-'0')*10+(b-'0')<=26);
    };
    vector<long> dp(N+1,0);
    dp[N]=1;
    dp[N-1]=1;
    for(int i=N-1;i--;){
        if(T[i]!='0'&&T[i+1]!='0') dp[i]+=dp[i+1];
        if(f(i)) dp[i]+=dp[i+2];
        chmin(dp[i], (long)2e18);
    }
    // rep(i,N+1)cout<<dp[i]<<" ";
    // cout<<"\n";

    int now=0;
    while(now!=N){
        if(K<=dp[now+1]&&T[now]!='0'&&(now+1<N||T[now+1]!='0')){
            cout<<(char)('a'+T[now]-'1');
            now++;
        }
        else{
            cout<<(char)('a'+((T[now]-'0')*10+T[now+1]-'1'));
            if(T[now]!='0'&&(now+1<N||T[now+1]!='0'))K-=dp[now+1];
            now+=2;
        }
    }
    cout<<"\n";
}
0