225972026-01-15 11:48:38AKrisztianSzínezéscpp17Time limit exceeded 20/50699ms892 KiB
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N, Q;
    cin >> N >> Q;
    string sor;
    cin >> sor;
    int K, p=0, k=0;
    bool pp=0, kk=0;

    for (int i=0; i<=Q; i++)
    {
        p=0;
        k=0;
        pp=0;
        kk=0;
        for (int j=0; j<N; j++)
        {
            if (sor[j]=='1' and kk==0)
            {
                kk=1;
                pp=0;
                k=k+1;
            }
            if (sor[j]=='0' and pp==0)
            {
                kk=0;
                pp=1;
                p=p+1;
            }
        }
        cout << min(k, p) << endl;
        cin >> K;
        if (sor[K-1]=='0')
        {
            sor[K-1]='1';
        }
        else
        {
            sor[K-1]='0';
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/01ms316 KiB
2Accepted0/065ms508 KiB
3Accepted2/22ms316 KiB
4Accepted2/22ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/34ms316 KiB
8Accepted3/34ms316 KiB
9Accepted2/24ms316 KiB
10Accepted2/24ms316 KiB
11Time limit exceeded0/3699ms708 KiB
12Time limit exceeded0/3699ms708 KiB
13Time limit exceeded0/3699ms708 KiB
14Time limit exceeded0/3699ms744 KiB
15Time limit exceeded0/3681ms708 KiB
16Time limit exceeded0/3699ms756 KiB
17Time limit exceeded0/3699ms708 KiB
18Time limit exceeded0/3699ms892 KiB
19Time limit exceeded0/3683ms748 KiB
20Time limit exceeded0/3699ms736 KiB