8.14比赛j题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87813#overview

就我个人来说我觉得这道题其实不用写题解,只是因为做的时候错了一次,如果不是队友细心,我根本会错下去,所以我感觉自己必须强大
#include<stdio.h> #include<string.h> #include<ctype.h> #include<queue> #include<algorithm> using namespace std; #define N 300100 int n, m, cnt; char str[N]; int v[N]; void solve(int a, char b); int main() { while(scanf("%d%d", &n, &m)!=EOF) { cnt=0; getchar(); gets(str); memset(v, 0, sizeof(v)); for(int j=1; j<n; j++) { if(str[j]=='.'&&str[j-1]=='.') { v[j]++; } cnt+=v[j]; } while(m--) { int a; char b; scanf("%d %c", &a, &b); solve(a, b); } } } void solve(int a, char b) { int ans=0; int i=a-1; if(b!='.'&&str[i]=='.') { str[i]=b; if(str[i-1]=='.') cnt-=1;//v[i]-=1; if(str[i+1]=='.') cnt-=1;//v[i+1]-=1; } else if(b=='.'&&str[i]!='.') { str[i]=b; if(str[i-1]=='.') cnt+=1;//v[i]+=1; if(str[i+1]=='.') cnt+=1;//v[i+1]+=1; } ans=cnt; printf("%d\n", ans); }

转载于:https://www.cnblogs.com/wazqWAZQ1/p/4731176.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值