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);
}
8.14比赛j题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87813#overview的更多相关文章
- 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] ...
- Acm hust 1.25
闲着无聊做了点hust上 acm的训练题 A题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=104738#problem/A 看了20分 ...
- 暑假集训第一周比赛C题
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/C C - 学 Crawling in process... C ...
- ACM hust 2.1
来自咸鱼王的呻吟 http://www.xiami.com/song/3599639?spm=a1z1s.3521865.23309997.1.PbLu7E 配合咸鱼食用效果更佳(右键新窗口打开) 题 ...
- 暑假集训第一周比赛G题
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/G G - 向 Crawling in process... C ...
- [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 ...
- HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题
第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...
- 2015 UESTC 搜索专题J题 全都是秋实大哥 kmp
全都是秋实大哥 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Desc ...
- 2019牛客暑期多校训练营(第四场)k题、j题
传送门 k题: 题意: 给你一串由数字构成的字符串,你从这个字符串中找子字符串使这个字符串是300的倍数 题解: 这道题和第三场的B题极其相似 首先可以把是三百的倍数分开,必须要是100和3的倍数 是 ...
随机推荐
- TFS2013安装与使用图文教程
from:http://www.jb51.net/softjc/214560.html TFS2013安装与使用图文教程 一.安装和配置过程介绍 要安装TFS2013当然要先进行下载了,可以在下面的地 ...
- 深入PHP内核 SAPI探究
转自 http://www.csdn.net/article/2014-09-26/2821885-exploring-of-the-php-2 SAPI是Server Application Pro ...
- Javascript中的函数中的this值
看下面这段代码会在控制台上输出什么内容? <script> var url="fang.com"; var obj={ url:"soufun.com&quo ...
- jQuery 文档操作方法(append)
这些方法对于 XML 文档和 HTML 文档均是适用的,除了:html(). 一.append() 方法 append() 方法在被选元素的结尾(仍然在内部)插入指定内容. 例子: <html& ...
- Brouwer fixed-point theorem
w https://en.wikipedia.org/wiki/Brouwer_fixed-point_theorem https://zh.wikipedia.org/wiki/布劳威尔不动点定理 ...
- ehcache 配置持久化到硬盘(四)
Ehcache默认配置的话 为了提高效率,所以有一部分缓存是在内存中,然后达到配置的内存对象总量,则才根据策略持久化到硬盘中,这里是有一个问题的,假如系统突然中断运行 那内存中的那些缓存,直接被释放掉 ...
- python面试题(三)
1 一行代码实现9*9乘法表 print ("\n".join("\t".join(["%s*%s=%s" %(x,y,x*y) for y ...
- A SELECT statement that assigns a value to a variable must ... (向变量赋值的 SELECT 语句不能与数据检索操作结合使用 )
A SELECT statement that assigns a value to a variable must ... (向变量赋值的 SELECT 语句不能与数据检索操作结合使用 ) 总结一句 ...
- LeNet5
Lecun Y, Bottou L, Bengio Y, et al. Gradient-based learning applied to document recognition[J]. Proc ...
- springboot 项目跨域问题 CORS
package com.example.demo.cors; import org.springframework.context.annotation.Bean; import org.spring ...