245812026-02-12 20:42:46999Színezéscpp17Wrong answer 0/50414ms5068 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n,q;cin>>n>>q;
    string s;cin>>s;
    int cnt=0;
    char curr='2';
    vector<int> balrol(n),jobbrol(n);
    for(char c:s){
        if(c!=curr){
            cnt++;
            curr=c;
        }
    }
    for(int i = 1;i<n;i++){
        if(s[i]!=s[i-1])balrol[i]=1;
    }
    for(int i = 0;i<n-1;i++){
        if(s[i]!=s[i+1])jobbrol[i]=1;
    }
    cout<<cnt/2<<endl;
    for(int i = 0;i<q;i++){
        int a;cin>>a;
        a--;
        if(balrol[a]&&jobbrol[a]){
            cnt-=2;
            balrol[a]=jobbrol[a]=0;
        }
        else if(balrol[a]){
            balrol[a]=0;
            if(a<n-1){
                balrol[a+1]=1;
            }
            else cnt--;
        }
        else if(jobbrol[a]){
            jobbrol[a]=0;
            if(a>0){
                jobbrol[a-1]=1;
            }
            else cnt--;
        }
        else{
            if(a<n-1){
                balrol[a+1]=1;
                cnt++;
            }
            if(a>0){
                jobbrol[a-1]=1;
                cnt++;
            }
            balrol[a]=1;
            jobbrol[a]=1;
        }
        cout<<cnt/2<<endl;
    }

}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms500 KiB
2Wrong answer0/03ms564 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/31ms508 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/33ms388 KiB
8Wrong answer0/33ms500 KiB
9Wrong answer0/23ms316 KiB
10Wrong answer0/23ms316 KiB
11Wrong answer0/3414ms4972 KiB
12Wrong answer0/3402ms5060 KiB
13Wrong answer0/3414ms4944 KiB
14Wrong answer0/3402ms5060 KiB
15Wrong answer0/3400ms5068 KiB
16Wrong answer0/3400ms4908 KiB
17Wrong answer0/3414ms5060 KiB
18Wrong answer0/3409ms5060 KiB
19Wrong answer0/3361ms5060 KiB
20Wrong answer0/3358ms4964 KiB