Gym 100712C Street Lamps
来源:互联网 发布:notepad 安装sql插件 编辑:程序博客网 时间:2024/04/30 22:22
题目链接:http://codeforces.com/gym/100712/attachments
水题,模拟一下就好了。
附上AC代码:
#include <bits/stdc++.h>//#pragma comment(linker, "/STACK:102400000, 102400000")using namespace std;const int maxn = 105;char str[maxn];bool vis[maxn];int n;int main(){#ifdef LOCALfreopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);#endifint T;scanf("%d", &T);while (T--){scanf("%d", &n);scanf("%s", str);int ans=0, len=strlen(str);memset(vis, false, sizeof(bool)*n);for (int i=0; i<len; ++i){if (str[i] == '*'){vis[i] = true;if (i-1>=0 && str[i-1]=='.')vis[i-1] = true;if (i+1<len && str[i+1]=='.')vis[i+1] = true;}}for (int i=0; i<len; ++i)if (!vis[i]){++ans;vis[i] = true;if (i+1<len && !vis[i+1])vis[i+1] = true;if (i+2<len && !vis[i+2])vis[i+2] = true;}printf("%d\n", ans);}return 0;}
1 0
- Gym-100712C-Street Lamps
- Gym 100712C Street Lamps
- GYM 100712 C.Street Lamps(贪心)
- Street Lamps
- ACM Amman Collegiate Programming Contest C. Street Lamps
- GYM 101147 B.Street(Floyd)
- lamps
- Street
- CodeForces Gym 100114C
- CodeForces Gym 100735C
- Gym 100971C Triangles
- codeforces Gym-101246C
- Codeforces gym 101243 C
- Gym 101164.C
- Gym 101243.C
- Gym 101246.C
- Gym 101482.C
- Cheering Gym-101522C
- Android存储(读取)之内存FilesDir存储
- 顺序表实现集合运算
- 【Leetcode】Combine Two Tables
- ubuntu鼠标滚轮方向修改方法(运动方向和滚轮滚动方向一致)
- Python-格式化字符串
- Gym 100712C Street Lamps
- 《java入门第一季》之Date类案例,算一算你的恋爱纪念日
- 链表操作
- 2016"百度之星" - 资格赛(Astar Round1)
- OCP 考完了, 做个记录,分享下经验
- ViewPager,子页面组件绑定OnClick事件,使用DepthPageTransformer动画,事件失效、混乱
- 1 HTML介绍
- C:数组
- centos下安装JDK8的方法