提出 #75427499


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

template<class T> inline bool chmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int MOD = 
998244353;

void solve() {
    string s;cin>>s;
    int n=s.size();
    // only 3charsacters;
    ll dp[3]={0,0,0};
    ll ans=0;
    for(char c:s){
        int idx=c-'a';
        ll newdp=(ans+1)%MOD;
        ans=(ans-dp[idx]+MOD)%MOD;
        dp[idx]=newdp;
        ans=(ans+dp[idx])%MOD;
    }
    cout<<ans<<'\n';
  
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    //cin>>tt;
    while (tt--) {
        solve();
    }

    return 0;
}

提出情報

提出日時
問題 D - Not Adjacent 2
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 400
コード長 942 Byte
結果 AC
実行時間 4 ms
メモリ 4096 KiB

コンパイルエラー

./Main.cpp: In function 'void solve()':
./Main.cpp:19:9: warning: unused variable 'n' [-Wunused-variable]
   19 |     int n=s.size();
      |         ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 28
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
min.txt AC 1 ms 3464 KiB
random_01.txt AC 4 ms 3804 KiB
random_02.txt AC 3 ms 3736 KiB
random_03.txt AC 4 ms 3948 KiB
random_04.txt AC 2 ms 3828 KiB
random_05.txt AC 4 ms 3776 KiB
random_06.txt AC 2 ms 3644 KiB
random_07.txt AC 4 ms 3984 KiB
random_08.txt AC 2 ms 3724 KiB
random_09.txt AC 4 ms 3840 KiB
random_10.txt AC 3 ms 3768 KiB
random_11.txt AC 4 ms 3944 KiB
random_12.txt AC 1 ms 3728 KiB
random_13.txt AC 4 ms 3784 KiB
random_14.txt AC 3 ms 3840 KiB
random_15.txt AC 4 ms 4096 KiB
random_16.txt AC 2 ms 3832 KiB
random_17.txt AC 4 ms 3872 KiB
random_18.txt AC 3 ms 3776 KiB
random_19.txt AC 4 ms 3780 KiB
random_20.txt AC 2 ms 3728 KiB
random_21.txt AC 4 ms 3960 KiB
random_22.txt AC 3 ms 3828 KiB
random_23.txt AC 4 ms 3836 KiB
random_24.txt AC 1 ms 3712 KiB
random_25.txt AC 4 ms 3900 KiB
sample_01.txt AC 1 ms 3620 KiB
sample_02.txt AC 1 ms 3508 KiB