Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define f(i,x,y) for(int i = x; i < y; i++)
- #define clr(A, x) memset(A, x, sizeof A)
- #define N 100005
- using namespace std;
- int n, m, pos, tot=0, act=0;
- string str;
- char c;
- int main(){
- cin>>n>>m;
- cin>>str;
- //Total inicial
- f(i,0,n){
- if(str[i]=='.') act++;
- else{
- if(act) tot+=(act-1);
- act=0;
- }
- }
- if(act) tot+=(act-1);
- //Depende solo de los costados, máximo las respuestas entre uno y otro caso varían en 2
- f(i,0,m){
- cin>>pos>>c;
- if( c==str[pos-1] || ( isalpha(c) && isalpha(str[pos-1]) ) ) cout<<tot<<endl;
- else{
- if(c=='.'){
- if(pos>1 && str[pos-2]=='.') tot++;
- if(pos<n && str[pos]=='.') tot++;
- }
- else{
- if(pos>1 && str[pos-2]=='.') tot--;
- if(pos<n && str[pos]=='.') tot--;
- }
- cout<<tot<<endl;
- str[pos-1]=c;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement