码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-08-14 21:12:04      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

就我个人来说我觉得这道题其实不用写题解,只是因为做的时候错了一次,如果不是队友细心,我根本会错下去,所以我感觉自己必须强大
#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); }

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

标签:

原文地址:http://www.cnblogs.com/wazqWAZQ1/p/4731176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!