Submission #75424343


Source Code Expand

#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned long long
#define inf 1e12
#define eps 1e-9
#define endl "\n"
#define il inline
#define ls 2*k
#define rs 2*k+1
using namespace std;
const int N=2e6+5,M=3e6+5;
const int mod=998244353;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n;
string s;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int tc=1; 
	while(tc--){
		cin>>s;
		n=s.size();
		s=" "+s; 
		int ans=0,r=1;
		for(int l=1;l<=n;l++){
			if(r<l) r=l;
			while(r<=n && ((r-l+1)<=1 || s[r]!=s[r-1])) ++r;
			ans=(ans+r-l)%mod;
		}
		cout<<ans<<'\n';
	}
	
	return 0;
}

Submission Info

Submission Time
Task C - Not Adjacent
User Limingxuan
Language C++23 (GCC 15.2.0)
Score 300
Code Size 851 Byte
Status AC
Exec Time 3 ms
Memory 4056 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
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
Case Name Status Exec Time Memory
min.txt AC 1 ms 3520 KiB
random_01.txt AC 3 ms 4024 KiB
random_02.txt AC 2 ms 3888 KiB
random_03.txt AC 3 ms 4052 KiB
random_04.txt AC 2 ms 3848 KiB
random_05.txt AC 3 ms 3920 KiB
random_06.txt AC 2 ms 3776 KiB
random_07.txt AC 3 ms 3924 KiB
random_08.txt AC 1 ms 3856 KiB
random_09.txt AC 3 ms 3864 KiB
random_10.txt AC 3 ms 3960 KiB
random_11.txt AC 3 ms 3916 KiB
random_12.txt AC 1 ms 3720 KiB
random_13.txt AC 3 ms 4028 KiB
random_14.txt AC 3 ms 3776 KiB
random_15.txt AC 3 ms 3860 KiB
random_16.txt AC 2 ms 3736 KiB
random_17.txt AC 3 ms 4056 KiB
random_18.txt AC 2 ms 3836 KiB
random_19.txt AC 3 ms 3996 KiB
random_20.txt AC 1 ms 3848 KiB
random_21.txt AC 3 ms 3924 KiB
random_22.txt AC 2 ms 3716 KiB
random_23.txt AC 3 ms 4000 KiB
random_24.txt AC 1 ms 3576 KiB
random_25.txt AC 3 ms 4052 KiB
sample_01.txt AC 1 ms 3528 KiB
sample_02.txt AC 1 ms 3528 KiB