Submission #75423050


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
string s;
long long cnt,ans;
int main(){
	cin>>s,s=" "+s;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]) cnt++;
		else (ans+=cnt*(cnt+1)/2%mod)%=mod,cnt=1;
	}
	(ans+=cnt*(cnt+1)/2%mod)%=mod,cnt=1;
	cout<<ans;
}

Submission Info

Submission Time
Task C - Not Adjacent
User Rya_
Language C++23 (GCC 15.2.0)
Score 300
Code Size 295 Byte
Status AC
Exec Time 7 ms
Memory 4088 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |         for(int i=1;i<s.size();i++){
      |                     ~^~~~~~~~~

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 3392 KiB
random_01.txt AC 5 ms 3852 KiB
random_02.txt AC 4 ms 3904 KiB
random_03.txt AC 5 ms 3860 KiB
random_04.txt AC 3 ms 3872 KiB
random_05.txt AC 5 ms 3988 KiB
random_06.txt AC 2 ms 3784 KiB
random_07.txt AC 6 ms 4016 KiB
random_08.txt AC 3 ms 3668 KiB
random_09.txt AC 6 ms 4012 KiB
random_10.txt AC 5 ms 3844 KiB
random_11.txt AC 6 ms 3924 KiB
random_12.txt AC 1 ms 3700 KiB
random_13.txt AC 6 ms 3832 KiB
random_14.txt AC 5 ms 3824 KiB
random_15.txt AC 7 ms 3952 KiB
random_16.txt AC 3 ms 3824 KiB
random_17.txt AC 6 ms 3832 KiB
random_18.txt AC 4 ms 3876 KiB
random_19.txt AC 6 ms 3992 KiB
random_20.txt AC 2 ms 3668 KiB
random_21.txt AC 6 ms 4012 KiB
random_22.txt AC 4 ms 3888 KiB
random_23.txt AC 6 ms 3856 KiB
random_24.txt AC 2 ms 3692 KiB
random_25.txt AC 6 ms 4088 KiB
sample_01.txt AC 1 ms 3484 KiB
sample_02.txt AC 1 ms 3412 KiB