zoukankan      html  css  js  c++  java
  • 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 ", ans); }
  • 相关阅读:
    PL/SQL注册码
    分页sql
    js获取url值
    C语言中的bool类型 stdbool.h
    语音朗读小程序
    50. Pow(x, n)
    二维数组旋转
    用一位数组代替二维数组作为形参使用
    单链表排序——交换数据成员
    C++重载输入流、输出流运算符
  • 原文地址:https://www.cnblogs.com/wazqWAZQ1/p/4731176.html
Copyright © 2011-2022 走看看