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

1713B - Optimal Reduction
1710A - Color the Picture
1686B - Odd Subarrays
251A - Points on Line
427C - Checkposts
1159A - A pile of stones
508A - Pasha and Pixels
912A - Tricky Alchemy
1249A - Yet Another Dividing into Teams
1713C - Build Permutation
1699A - The Third Three Number Problem
1617B - GCD Problem
841A - Generous Kefa
1690B - Array Decrements
1692C - Where's the Bishop
104A - Blackjack
1438A - Specific Tastes of Andre
1711C - Color the Picture
1194C - From S To T
110B - Lucky String
1114A - Got Any Grapes
224B - Array
125B - Simple XML
567B - Berland National Library
431B - Shower Line
282C - XOR and OR
1582B - Luntik and Subsequences
609A - Флеш-карты
1207A - There Are Two Types Of Burgers
371C - Hamburgers