Submission #68325031


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#define ALL(v) v.begin(),v.end()
#define For(i,_) for(int i=0,i##end=_;i<i##end;++i) // [0,_)
#define FOR(i,_,__) for(int i=_,i##end=__;i<i##end;++i) // [_,__)
#define Rep(i,_) for(int i=(_)-1;i>=0;--i) // [0,_)
#define REP(i,_,__) for(int i=(__)-1,i##end=_;i>=i##end;--i) // [_,__)
typedef long long ll;
typedef unsigned long long ull;
#define V vector
#define pb push_back
#define pf push_front
#define qb pop_back
#define qf pop_front
#define eb emplace_back
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
#define fi first
#define se second
const int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}},inf=0x3f3f3f3f,mod=1e9+7;
const ll infl=0x3f3f3f3f3f3f3f3fll;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
int init=[](){return cin.tie(nullptr)->sync_with_stdio(false),0;}();
int main(){
    int t_case=1;
    //scanf("%d",&t_case);
    while(t_case--){
        int n;
        string s;
        cin>>n>>s;
        V<int>cnt(2);
        ++cnt[0];
        ll ans=0;
        int x=0;
        for(char c:s){
            if(c^49)x^=1;
            ans+=cnt[x]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Submission Info

Submission Time
Task D - XNOR Operation
User zzr
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1367 Byte
Status AC
Exec Time 2 ms
Memory 3960 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 03_corner_00.txt, 03_corner_01.txt, 03_corner_02.txt, 03_corner_03.txt, 03_corner_04.txt, 03_corner_05.txt, 03_corner_06.txt, 03_corner_07.txt, 03_corner_08.txt, 03_corner_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3708 KiB
00_sample_01.txt AC 1 ms 3768 KiB
00_sample_02.txt AC 1 ms 3772 KiB
01_small_00.txt AC 1 ms 3704 KiB
01_small_01.txt AC 1 ms 3580 KiB
01_small_02.txt AC 1 ms 3772 KiB
01_small_03.txt AC 1 ms 3592 KiB
01_small_04.txt AC 1 ms 3772 KiB
01_small_05.txt AC 1 ms 3772 KiB
02_random_00.txt AC 2 ms 3896 KiB
02_random_01.txt AC 2 ms 3884 KiB
02_random_02.txt AC 2 ms 3748 KiB
02_random_03.txt AC 2 ms 3892 KiB
02_random_04.txt AC 2 ms 3868 KiB
02_random_05.txt AC 2 ms 3752 KiB
02_random_06.txt AC 2 ms 3896 KiB
02_random_07.txt AC 2 ms 3760 KiB
02_random_08.txt AC 2 ms 3888 KiB
02_random_09.txt AC 2 ms 3960 KiB
03_corner_00.txt AC 2 ms 3812 KiB
03_corner_01.txt AC 2 ms 3752 KiB
03_corner_02.txt AC 2 ms 3888 KiB
03_corner_03.txt AC 1 ms 3708 KiB
03_corner_04.txt AC 1 ms 3824 KiB
03_corner_05.txt AC 2 ms 3760 KiB
03_corner_06.txt AC 2 ms 3816 KiB
03_corner_07.txt AC 1 ms 3828 KiB
03_corner_08.txt AC 1 ms 3820 KiB
03_corner_09.txt AC 2 ms 3824 KiB