78132024-01-11 10:54:39szabelrSzínezéscpp17Wrong answer 0/50699ms4492 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()
{
    long long 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+1; i++) {
        if (x[i-1] == '0') {
            tomb[i] = 0;
        }
        else
            tomb[i] = 1;
    }
    for (int i = 1; i <= q + 1; i++) {
        cout << tomb[i] << endl;
    }
    //0-ra
    while (hol <= n)
    {
        if (tomb[hol] == 1) {
            while (tomb[hol] == 1)
            {
                hol++;
            }
            db++;
        }
        if (tomb[hol] == 0) {
            hol++;
        }
    }
    dbmax = db;
    db = 0;
    hol = 1;
    //1re
    while (hol <= n)
    {
        if (tomb[hol] == 0) {
            while (tomb[hol] == 0)
            {
                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;
        hol = 1;
        dbmax = 0;
        //0-ra
        while (hol <= n)
        {
            if (tomb[hol] == 1) {
                while (tomb[hol] == 1)
                {
                    hol++;
                }
                db++;
            }
            if (tomb[hol] == 0) {
                hol++;
            }
        }
        dbmax = db;
        db = 0;
        //1re
        hol = 1;
        while (hol <= n)
        {
            if (tomb[hol] == 0) {
                while (tomb[hol] == 0)
                {
                    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
1Wrong answer0/03ms1820 KiB
2Wrong answer0/0119ms2288 KiB
3Wrong answer0/23ms2228 KiB
4Wrong answer0/23ms2308 KiB
5Wrong answer0/33ms2536 KiB
6Wrong answer0/33ms2632 KiB
7Wrong answer0/310ms2548 KiB
8Wrong answer0/39ms2796 KiB
9Wrong answer0/210ms2588 KiB
10Wrong answer0/29ms2592 KiB
11Time limit exceeded0/3699ms3616 KiB
12Time limit exceeded0/3671ms3596 KiB
13Time limit exceeded0/3660ms3928 KiB
14Time limit exceeded0/3651ms4092 KiB
15Time limit exceeded0/3675ms4084 KiB
16Time limit exceeded0/3667ms4204 KiB
17Time limit exceeded0/3654ms4276 KiB
18Time limit exceeded0/3651ms4492 KiB
19Time limit exceeded0/3671ms4432 KiB
20Time limit exceeded0/3680ms4452 KiB