17842022-12-03 14:50:341478Színezéscpp11Time limit exceeded 20/50677ms3576 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");

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    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/03ms1824 KiB
2Accepted0/085ms2180 KiB
3Accepted2/22ms2228 KiB
4Accepted2/22ms2432 KiB
5Accepted3/32ms2632 KiB
6Accepted3/32ms2836 KiB
7Accepted3/38ms2920 KiB
8Accepted3/38ms2916 KiB
9Accepted2/28ms3136 KiB
10Accepted2/27ms3216 KiB
11Time limit exceeded0/3658ms2796 KiB
12Time limit exceeded0/3677ms2880 KiB
13Time limit exceeded0/3657ms2948 KiB
14Time limit exceeded0/3666ms3108 KiB
15Time limit exceeded0/3677ms3200 KiB
16Time limit exceeded0/3666ms3112 KiB
17Time limit exceeded0/3628ms3324 KiB
18Time limit exceeded0/3662ms3456 KiB
19Time limit exceeded0/3674ms3576 KiB
20Time limit exceeded0/3674ms3536 KiB