825A - Binary Protocol - CodeForces Solution


implementation *1100

Please click on ads to support us..

C++ Code:

// 1677685109140
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define f(i, x, n) for (int i = x; i < n; ++i)
#define rf(i, x, n) for (int i = x; i >= n; --i)
#define fr(i, m) for (auto &i : m)
#define pl pair<long long, long long>
#define vl vector<long long>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rll(v) (v).begin(), (v).end(), greater<ll>()
#define si size()
#define lcm(a, b) ((a * b) / (__gcd(a, b)))

#define time_nhi_hai ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
long double fast_pow(long double a, int p)
{
    long double ret = 1.;
    for (; p; p /= 2, a *= a)
        if (p & 1)
            ret *= a;
    return ret;
}
bool isprime(ll number)
{
    if (number <= 1)
        return false;
    if (number == 2)
        return true;
    if (number % 2 == 0)
        return false;
    int boundary = (int)floor(sqrt(number));
    for (int i = 3; i <= boundary; i += 2)
        if (number % i == 0)
            return false;
    return true;
}
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        b = b / 2;
    }
    return ans;
}
vector<int> Sieve(int n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for (int p = 2; p * p <= n; p++)
    {
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    vector<int> vec;
    for (int p = 2; p <= n; p++)
        if (prime[p])
            vec.push_back(p);
    return vec;
}

int main()
{
    time_nhi_hai;

    ll n, m;
    string s;

    cin >> n >> s;

    ll k = 0;
    for (ll i = 0; i < n; i++)
    {
        if (s[i] == '1')
            k++;

        else
        {
            cout << k;
            k = 0;
        }
    }

    cout << k;
}


Comments

Submit
0 Comments
More Questions

1618A - Polycarp and Sums of Subsequences
1618B - Missing Bigram
938. Range Sum of BST
147. Insertion Sort List
310. Minimum Height Trees
2110. Number of Smooth Descent Periods of a Stock
2109. Adding Spaces to a String
2108. Find First Palindromic String in the Array
394. Decode String
902. Numbers At Most N Given Digit Set
221. Maximal Square
1200. Minimum Absolute Difference
1619B - Squares and Cubes
1619A - Square String
1629B - GCD Arrays
1629A - Download More RAM
1629C - Meximum Array
1629D - Peculiar Movie Preferences
1629E - Grid Xor
1629F1 - Game on Sum (Easy Version)
2148. Count Elements With Strictly Smaller and Greater Elements
2149. Rearrange Array Elements by Sign
2150. Find All Lonely Numbers in the Array
2151. Maximum Good People Based on Statements
2144. Minimum Cost of Buying Candies With Discount
Non empty subsets
1630A - And Matching
1630B - Range and Partition
1630C - Paint the Middle
1630D - Flipping Range