Submission #71136465


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a),E##i=(b);i<=E##i;i++)
#define REV(i,a,b) for(int i=(a),E##i=(b);i>=E##i;i--)
#define CLOSE_TIE ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define psbk push_back
#define endl '\n'
template <typename T>
void _outval(string s,int p,const T &t) {cout<<s.substr(p,s.length()-p)<<'='<<t<<endl; }
template <typename T, typename... Args>
void _outval(string s,int p,const T &t,const Args &...rest){
    string n="";
    while(s[p]!=',') n+=s[p++];
    cout<<n<<'='<<t<<", ";
    _outval(s,p+1,rest...);
}
#define outval(...) _outval(#__VA_ARGS__,0,__VA_ARGS__)
#define outarr(a,be,ed)\
{cout<<(#a)<<": ";\
FOR(iiii,be,ed)cout<<'['<<iiii<<"]="<<a[iiii]<<(iiii<ed?", ":"\n");}
const int N=1e6+5;
string s;
int n,id[N],cnt;
char num[N];
ll ans,len[N];
signed main(){
    CLOSE_TIE
    cin>>s;
    n=s.size(); s='!'+s;
    id[1]=++cnt; len[id[1]]=1; num[1]=s[1];
    FOR(i,2,n){
        if(s[i]==s[i-1]) id[i]=id[i-1],++len[id[i]];
        else id[i]=++cnt,num[cnt]=s[i],len[cnt]=1;
    }
    //outarr(len,1,cnt); outarr(id,1,n); outarr(num,1,cnt);
    FOR(i,2,cnt){
        if(num[i]=='0') continue;
        if(num[i]-1!=num[i-1]) continue;
        ans+=min(len[i],len[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - 1122 Substring 2
User FYCCCTA2011
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1358 Byte
Status AC
Exec Time 11 ms
Memory 17212 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 23
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3596 KiB
00_sample_01.txt AC 2 ms 3596 KiB
00_sample_02.txt AC 1 ms 3620 KiB
00_sample_03.txt AC 1 ms 3672 KiB
01_random_00.txt AC 1 ms 3628 KiB
01_random_01.txt AC 6 ms 8228 KiB
01_random_02.txt AC 6 ms 8364 KiB
01_random_03.txt AC 6 ms 8348 KiB
01_random_04.txt AC 6 ms 8348 KiB
01_random_05.txt AC 6 ms 8328 KiB
01_random_06.txt AC 9 ms 14484 KiB
01_random_07.txt AC 10 ms 16188 KiB
01_random_08.txt AC 4 ms 7364 KiB
01_random_09.txt AC 11 ms 13116 KiB
01_random_10.txt AC 10 ms 12836 KiB
01_random_11.txt AC 9 ms 12812 KiB
01_random_12.txt AC 9 ms 12828 KiB
01_random_13.txt AC 5 ms 9280 KiB
01_random_14.txt AC 5 ms 9296 KiB
01_random_15.txt AC 9 ms 16316 KiB
01_random_16.txt AC 9 ms 16320 KiB
01_random_17.txt AC 7 ms 12680 KiB
01_random_18.txt AC 9 ms 17212 KiB