17832022-12-03 14:48:581478Színezéscpp11Time limit exceeded 20/50675ms3464 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    //ifstream cin("be.txt");

    int n;
    cin >> n;

    int q;
    cin >> q;

    string s;
    cin >> s;

    q++;

    while (q--)
    {
        int i = 0;
        vector<int> c(2);
        while (i < n)
        {
            if (s[i] != s[i - 1] || i == 0)
            {
                c[s[i] - '0']++;
            }
            i++;
        }
        cout << min(c[0], c[1]) << ln;

        int change;
        cin >> change;
        change--;
        s[change] = abs(s[change] - '1') + '0';
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/03ms1812 KiB
2Accepted0/074ms1952 KiB
3Accepted2/22ms2140 KiB
4Accepted2/22ms2344 KiB
5Accepted3/32ms2416 KiB
6Accepted3/32ms2540 KiB
7Accepted3/39ms2624 KiB
8Accepted3/310ms2752 KiB
9Accepted2/29ms2996 KiB
10Accepted2/28ms3200 KiB
11Time limit exceeded0/3656ms2784 KiB
12Time limit exceeded0/3662ms3032 KiB
13Time limit exceeded0/3663ms2988 KiB
14Time limit exceeded0/3662ms3044 KiB
15Time limit exceeded0/3675ms2988 KiB
16Time limit exceeded0/3671ms2992 KiB
17Time limit exceeded0/3649ms3196 KiB
18Time limit exceeded0/3671ms3380 KiB
19Time limit exceeded0/3656ms3464 KiB
20Time limit exceeded0/3666ms3400 KiB