66492023-12-15 10:51:28zsebiSzínezéscpp14Wrong answer 0/50524ms4276 KiB
// szinezes.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>

#define ll long long 
using namespace std;
ll n, k, csop1 = 0,csop0=0;
int main()
{
    cin >> n >> k;
    vector<char>x(n + 2,'2');
    for (int i = 1; i <= n; ++i)
    {
        cin >> x[i];
        if (x[i] != x[i - 1])
        {
            if (x[i] == '1')
                csop1++;
            else csop0++;
        }
    }
    cout << min(csop0, csop1) << "\n";
    while (k--)
    {
        int i;
        cin >> i;
        if (i == 1 || i == n)
        {
            if (x[i] == '1')
            {
                if (x[i - 1] == '1' || x[i + 1] == '1')
                {
                    csop0++;
                }
                else csop1--;
                x[i] = '0';
            }
            else
            {
                if (x[i - 1] == '0' || x[i + 1] == '0')
                    csop1++;
                else csop0--;
                x[i] = '1';
            }
           
        }
        else if (x[i - 1] != x[i] && x[i + 1] != x[i])
        {
            csop1--;
            csop0--;
            if (x[i] == '1')
                x[i] = '0';
            else x[i] = '1';
        }
        cout << min(csop0, csop1)<<"\n";
       
    }
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1960 KiB
2Wrong answer0/04ms2188 KiB
3Wrong answer0/23ms2420 KiB
4Wrong answer0/23ms2476 KiB
5Wrong answer0/33ms2516 KiB
6Wrong answer0/33ms2664 KiB
7Wrong answer0/34ms2944 KiB
8Wrong answer0/34ms3044 KiB
9Wrong answer0/24ms3164 KiB
10Wrong answer0/26ms3172 KiB
11Wrong answer0/3449ms3412 KiB
12Wrong answer0/3515ms3540 KiB
13Wrong answer0/3465ms3688 KiB
14Wrong answer0/3524ms3976 KiB
15Wrong answer0/3356ms4204 KiB
16Wrong answer0/3305ms4188 KiB
17Wrong answer0/3522ms4124 KiB
18Wrong answer0/3470ms4016 KiB
19Wrong answer0/3449ms4016 KiB
20Wrong answer0/3405ms4276 KiB