77892024-01-11 10:13:22szabelrSzínezéscpp17Wrong answer 0/50430ms10336 KiB
// Színezés.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
using namespace std;
long long tomb[200001];
long long jok[200001];
int main()
{
    int n, q,hol=1,db=0,dbmax,z,dbog=1,hany=2;
    string x;
    cin >> n >> q;
    cin >> x;
    for (int i = 1; i <= n; i++) {
        if (x[i] == '0') {
            tomb[i] = 0;
        }
        else
            tomb[i] = 1;
    }
    //0-ra
    while (hol <= n)
    {
        if (tomb[hol] == 1) {
            while (tomb[hol] == 1)
            {
                tomb[hol];
                hol++;
            }
            db++;
        }
        if (tomb[hol] == 0) {
            hol++;
        }
    }
    dbmax = db;
    db = 1;
    //1re
    while (hol < n)
    {
        if (tomb[hol] == 0) {
            while (tomb[hol] == 0)
            {
                tomb[hol];
                hol++;
            }
            db++;
        }
        if (tomb[hol] == 1) {
            hol++;
        }
    }
    if (db > dbmax)
        dbmax = db;
    jok[1] = dbmax;

    for (int i = 1; i <= q; i++) {
        cin >> z;
        if (tomb[z] == 1)
            tomb[z] = 0;
        else
            tomb[z] = 1;
        db = 0;
        dbmax = 0;
        //0-ra
        while (hol <= n)
        {
            if (tomb[hol] == 1) {
                while (tomb[hol] == 1)
                {
                    tomb[hol];
                    hol++;
                }
                db++;
            }
            if (tomb[hol] == 0) {
                hol++;
            }
        }
        dbmax = db;
        db = 1;
        //1re
        while (hol < n)
        {
            if (tomb[hol] == 0) {
                while (tomb[hol] == 0)
                {
                    tomb[hol];
                    hol++;
                }
                db++;
            }
            if (tomb[hol] == 1) {
                hol++;
            }
        }
        if (db > dbmax)
            dbmax = db;
        jok[hany] = dbmax;
        hany++;
    }
    for (int i = 1; i <= q + 1; i++) {
        cout << jok[i]<<endl;
    }

}

// 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/03ms1820 KiB
2Wrong answer0/04ms2140 KiB
3Wrong answer0/23ms1980 KiB
4Wrong answer0/23ms2100 KiB
5Wrong answer0/33ms2316 KiB
6Wrong answer0/33ms2532 KiB
7Wrong answer0/34ms2744 KiB
8Wrong answer0/34ms3076 KiB
9Wrong answer0/24ms3312 KiB
10Wrong answer0/24ms3288 KiB
11Wrong answer0/3354ms10336 KiB
12Wrong answer0/3351ms10292 KiB
13Wrong answer0/3361ms10288 KiB
14Wrong answer0/3360ms10148 KiB
15Wrong answer0/3356ms10268 KiB
16Wrong answer0/3393ms10268 KiB
17Wrong answer0/3430ms10140 KiB
18Wrong answer0/3421ms10160 KiB
19Wrong answer0/3384ms10272 KiB
20Wrong answer0/3428ms10276 KiB