提出 #75423172


ソースコード 拡げる

#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();
    ll ans=0,curr=1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]){
            curr++;
        }
        else {
            ll sub=(curr*(curr+1)/2)%MOD;
            ans=(ans+sub)%MOD;
            curr=1;
        }
    }
    ll sub=(curr*(curr+1)/2)%MOD;
    ans=(ans+sub)%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;
}

提出情報

提出日時
問題 C - Not Adjacent
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1009 Byte
結果 AC
実行時間 3 ms
メモリ 4100 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
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 2 ms 3876 KiB
random_02.txt AC 1 ms 3832 KiB
random_03.txt AC 2 ms 3908 KiB
random_04.txt AC 1 ms 3824 KiB
random_05.txt AC 1 ms 4044 KiB
random_06.txt AC 1 ms 3772 KiB
random_07.txt AC 2 ms 3784 KiB
random_08.txt AC 1 ms 3720 KiB
random_09.txt AC 2 ms 3912 KiB
random_10.txt AC 2 ms 3712 KiB
random_11.txt AC 2 ms 3916 KiB
random_12.txt AC 1 ms 3704 KiB
random_13.txt AC 3 ms 3748 KiB
random_14.txt AC 2 ms 3708 KiB
random_15.txt AC 3 ms 3876 KiB
random_16.txt AC 1 ms 3772 KiB
random_17.txt AC 2 ms 3800 KiB
random_18.txt AC 2 ms 3756 KiB
random_19.txt AC 2 ms 4100 KiB
random_20.txt AC 1 ms 3684 KiB
random_21.txt AC 2 ms 3876 KiB
random_22.txt AC 2 ms 3728 KiB
random_23.txt AC 2 ms 3924 KiB
random_24.txt AC 1 ms 3644 KiB
random_25.txt AC 2 ms 3804 KiB
sample_01.txt AC 1 ms 3456 KiB
sample_02.txt AC 1 ms 3464 KiB