Untitled
user_5668965
c_cpp
a year ago
2.0 kB
15
Indexable
#define _ijps 0
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:667772160")
#include <iostream>
#include <cmath>
#include <vector>
#include <time.h>
#include <map>
#include <set>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <string>
#include <fstream>
#include <assert.h>
#include <list>
#include <cstring>
using namespace std;
#define name ""
typedef unsigned long long ull;
typedef long long ll;
#define mk make_pair
#define forn(i, n) for(ll i = 0; i < (ll)n; i++)
#define fornn(i, q, n) for(ll i = (ll)q; i < (ll)n; i++)
#define times clock() * 1.0 / CLOCKS_PER_SEC
#define inb push_back
struct __isoff{
__isoff(){
if (_ijps)
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);//, freopen("test.txt", "w", stderr);
//else freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);
//ios_base::sync_with_stdio(0);
srand(time(0));
//srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
}
~__isoff(){
//if(_ijps) cout<<times<<'\n';
}
} __osafwf;
const ull p1 = 31;
const ull p2 = 29;
const double eps = 1e-8;
const double pi = acos(-1.0);
const ll inf = 1e17 + 7;
const int infi = 1e9 + 7;
const ll dd = 3e5 + 7;
const ll mod = 1e9 + 7;
string s;
char t = '.';
int n, m;
int num, group;
bool ok[dd];
int main(){
cin >> n >> m >> s;
forn(i, n){
if(s[i] == t){
num++;
if(i == 0 || s[i - 1] != t)
group++;
ok[i + 1] = 1;
}
}
forn(i, m){
int d;
char c;
scanf("%d %c", &d, &c);
bool a = ok[d], b = c == t;
if(a != b){
if(a){
num--;
}
else{
num++;
}
if(ok[d - 1] && ok[d + 1] && !b){
group++;
}
if(ok[d - 1] && ok[d + 1] && b){
group--;
}
if(!ok[d - 1] && !ok[d + 1] && !b){
group--;
}
if(!ok[d - 1] && !ok[d + 1] && b){
group++;
}
}
ok[d] = b;
printf("%d\n", num - group);
}
}Editor is loading...
Leave a Comment