Source Code
#include<iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    
    int holiday=0;
    
    for(char c : s){
        if(c == '1'){
            holiday++;
        }
    }
    
    for(int i=1; i<s.size(); i++){
        if(s[i-1]=='1' && s[i]=='0' && s[i+1]=='1'){
            holiday++;
        }
    }
    cout << holiday;
    return 0;
}
Copy
Japanese holidays zagha.az
GNU G++17
5 ms
1.3 MB
Accepted