231182026-01-16 12:36:45MrkzSzínezéscpp17Wrong answer 0/50699ms808 KiB
#include <bits/stdc++.h>

using namespace std;

int minszinezes(string &szinek,int V){
    int db_0 = 0;
    int db_1 = 0;
        if (szinek[0] == '0')
        {
            db_0++;
        }
        else
        {
            db_1++;
        }
 for (int i = 1; i < V; i++)
        {
            if (szinek[i] != szinek[i - 1])
            {
                if (szinek[i] == '0')
                {
                    db_0++;
                }
                else
                {
                    db_1++;
                }
            }
        }
        return min(db_0, db_1);
}

void atszinez(string &szinek,int V,int index){
    szinek[index] = szinek[index] == '0' ? '1' : '0'; 
    for(int i=index + 1; i < V && szinek[i] != szinek[i - 1]; i++ ){
        szinek[i] = szinek[i - 1];
    }
    for(int i=index - 1; i > 0 && szinek[i] != szinek[i + 1]; i-- ){
        szinek[i] = szinek[i + 1];
    }
    
}

int main()
{
    const int max1 = 200000;

    istream *in;
    ifstream f("D:/njudge/be1.txt");

    //in = &f;
     in = &cin;

    int V, Q;
    (*in) >> V >> Q;
    int osszvaltozas = Q;
    string szinek;
    (*in) >> szinek;
    cout << minszinezes(szinek,V)<<'\n';
//cout<<szinek<<endl;

        for (int i = 0; i < Q; i++)
        {
            string tmpszinek = szinek;
            
            int index;
            (*in) >> index;
            atszinez(tmpszinek,V,index-1);
            //cout<<tmpszinek<<endl;
            cout << minszinezes(tmpszinek,V)<<'\n';
        }


        return 0;
    }
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/01ms316 KiB
2Wrong answer0/065ms508 KiB
3Wrong answer0/22ms316 KiB
4Wrong answer0/22ms396 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms400 KiB
7Wrong answer0/34ms316 KiB
8Wrong answer0/34ms316 KiB
9Wrong answer0/24ms316 KiB
10Wrong answer0/24ms508 KiB
11Time limit exceeded0/3699ms784 KiB
12Time limit exceeded0/3699ms784 KiB
13Time limit exceeded0/3699ms772 KiB
14Time limit exceeded0/3683ms764 KiB
15Time limit exceeded0/3680ms768 KiB
16Time limit exceeded0/3680ms780 KiB
17Time limit exceeded0/3683ms768 KiB
18Time limit exceeded0/3699ms808 KiB
19Time limit exceeded0/3681ms768 KiB
20Time limit exceeded0/3681ms768 KiB