// 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
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
base | 0/50 | ||||||
1 | Elfogadva | 0/0 | 3ms | 1960 KiB | |||
2 | Hibás válasz | 0/0 | 4ms | 2188 KiB | |||
3 | Hibás válasz | 0/2 | 3ms | 2420 KiB | |||
4 | Hibás válasz | 0/2 | 3ms | 2476 KiB | |||
5 | Hibás válasz | 0/3 | 3ms | 2516 KiB | |||
6 | Hibás válasz | 0/3 | 3ms | 2664 KiB | |||
7 | Hibás válasz | 0/3 | 4ms | 2944 KiB | |||
8 | Hibás válasz | 0/3 | 4ms | 3044 KiB | |||
9 | Hibás válasz | 0/2 | 4ms | 3164 KiB | |||
10 | Hibás válasz | 0/2 | 6ms | 3172 KiB | |||
11 | Hibás válasz | 0/3 | 449ms | 3412 KiB | |||
12 | Hibás válasz | 0/3 | 515ms | 3540 KiB | |||
13 | Hibás válasz | 0/3 | 465ms | 3688 KiB | |||
14 | Hibás válasz | 0/3 | 524ms | 3976 KiB | |||
15 | Hibás válasz | 0/3 | 356ms | 4204 KiB | |||
16 | Hibás válasz | 0/3 | 305ms | 4188 KiB | |||
17 | Hibás válasz | 0/3 | 522ms | 4124 KiB | |||
18 | Hibás válasz | 0/3 | 470ms | 4016 KiB | |||
19 | Hibás válasz | 0/3 | 449ms | 4016 KiB | |||
20 | Hibás válasz | 0/3 | 405ms | 4276 KiB |