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

  1. KMP(http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2772)

    #include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001],b[1000001] ...

  2. Acm hust 1.25

    闲着无聊做了点hust上 acm的训练题 A题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=104738#problem/A 看了20分 ...

  3. 暑假集训第一周比赛C题

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/C C - 学 Crawling in process... C ...

  4. ACM hust 2.1

    来自咸鱼王的呻吟 http://www.xiami.com/song/3599639?spm=a1z1s.3521865.23309997.1.PbLu7E 配合咸鱼食用效果更佳(右键新窗口打开) 题 ...

  5. 暑假集训第一周比赛G题

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/G G - 向 Crawling in process... C ...

  6. [ACM] HUST 1017 Exact cover (Dancing Links,DLX模板题)

    DESCRIPTION There is an N*M matrix with only 0s and 1s, (1 <= N,M <= 1000). An exact cover is ...

  7. HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题

    第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...

  8. 2015 UESTC 搜索专题J题 全都是秋实大哥 kmp

    全都是秋实大哥 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Desc ...

  9. 2019牛客暑期多校训练营(第四场)k题、j题

    传送门 k题: 题意: 给你一串由数字构成的字符串,你从这个字符串中找子字符串使这个字符串是300的倍数 题解: 这道题和第三场的B题极其相似 首先可以把是三百的倍数分开,必须要是100和3的倍数 是 ...

随机推荐

  1. Android-ViewPagerIndicator框架使用——UnderlinePageIndicator

    前言:UnderlinePageIndicator这个指示,是一个很小巧的东西,简单,没有那么多复杂的效果. 一:布局定义simple_underlines: <LinearLayout xml ...

  2. vim杂记

    "clang-completelet g:clang_complete_copen=1let g:clang_periodic_quickfix=1let g:clang_snippets= ...

  3. ios - 上下滚动的新闻

    #import <UIKit/UIKit.h> @interface ScrollUpDownView : UIView //设置 要现实的文字 @property(nonatomic, ...

  4. React ES5 (createClass) 和 ES6 (class)

    https://www.w3cplus.com/react/react-es5-createclass-vs-es6-classes.html http://blog.csdn.net/shaleil ...

  5. windows下 兼容Python2和Python3

    windows下同时安装了python2和python3时,都可以配置环境变量,如果在命令行里输入python命令,windows会去环境变量里寻找Python的安装位置,如果先找到pytoon2的, ...

  6. SharePoint服务器端对象模型 之 访问文件和文件夹(Part 3)

    (三)遍历 文件系统的遍历是指按照文件夹的层级结构遍历文档库.列表的文件夹和列表条目.遍历主要有三种方式:(1)直接使用文件系统对象模型进行遍历:(2)使用SPDocumentLibrary进行遍历: ...

  7. Java 自带的加密类MessageDigest类(加密MD5和SHA)

    Java 自带的加密类MessageDigest类(加密MD5和SHA) - X-rapido的专栏 - CSDN博客 https://blog.csdn.net/xiaokui_wingfly/ar ...

  8. <2013 08 26> 雅思听力相关

    近两日开始接触雅思题型,初步做了6套剑桥雅思题的听力部分,完成情况还可以,这里做个总结. 1.听力总共约40左右道题目,30min左右完成,结束后有十分钟把答案写到答题卷上.所有听力材料都只播放一遍! ...

  9. 为什么一定要调用 setlocale 呢? 因为在 C/C++ 语言标准中定义了其运行时的字符集环境为 "C" ,也就是 ASCII 字符集的一个子集。使用setlocal改变整个应用程序的字符集编码方式(wcstombs使用前要设置 setlocale (LC_ALL, "chs"); )

    setlocale 配置地域化信息. 语法: string setlocale(string category, string locale); 返回值: 字符串 函数种类: 操作系统与环境   内容 ...

  10. TypeError: save() missing 1 required positional argument: 'self'

    RT,在创建模型对象的时候,提示TypeError: save() missing 1 required positional argument: 'self' 解决办法:在创建模型对象的时候需要加上 ...