Codeforces 6B
来源:互联网 发布:程序员的自我修养txt 编辑:程序博客网 时间:2024/06/16 10:21
前面的题目确实很水啊。
题目大意:给定一个字符串矩阵和一个字符C,求与含C的子字符串矩阵边相邻的字符种类数(大写拉丁字母),n,m<=100。
我的思路是找出所给矩阵的左上右下,暴力枚举四条边相邻的元素,计数器++。
不管多么水的题都要%%%__debug大神。保佑我noip不挂。
#include<cstdio>#include<cstring>#include<cstdlib>#include<cstring>#include<algorithm>#include<iostream>#include<map>using namespace std;const int MAXN=101;char G[MAXN][MAXN]={},Pre;int n,m,x1,y1,x2,y2,flag;map<char,bool> mp;int main(){ int ans=0; scanf("%d %d %c",&n,&m,&Pre); for(int i=1;i<=n;i++) { scanf("%s",G[i]+1); for(int j=1;j<=strlen(G[i]+1);j++) if(G[i][j]==Pre&&!flag) x1=i,y1=j,flag=1; } flag=0; for(int i=n;i>=1;i--) for(int j=m;j>=1;j--) if(G[i][j]==Pre&&!flag) {x2=i,y2=j,flag=1;break;} for(int i=x1;i<=x2;i++) { mp[G[i][y1-1]]=1; mp[G[i][y2+1]]=1; } for(int i=y1;i<=y2;i++) { mp[G[x1-1][i]]=1; mp[G[x2+1][i]]=1; } for(int i='A';i<='Z';i++) { if(mp.count(i))ans++; } printf("%d\n",ans);}
0 0
- Codeforces 6B
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- codeforces 6B. President's Office
- codeforces 6B President's Office
- Codeforces 6B. President's Office
- CodeForces 6B - President's Office
- Educational Codeforces Round 6 (B)模拟
- CodeForces 6B President's Office
- CodeForces 6B President's Office
- CodeForces 626B CodeForces 626B【暴力】
- CodeForces 841B (B) 博弈
- codeforces 134B
- codeforces#98 b
- codeforces 105 div2 B
- Codeforces 166B - Polygons
- 设计模式之代理模式
- jeecms标签对应的类,方便查找标签的输入输出参数,以及参数对应的数值类型、范围
- 关于Qt中自定义槽和信号的简单示例
- 小白学开发(iOS)OC_ 从文件中读取字符串内容(2015-08-14)
- XSS教程
- Codeforces 6B
- js易错总结
- OC - Block
- ConcurrentHashMap浅析
- C/C++语言内存对齐
- Ubuntu linux 上搭建SERVER的相关使用说明
- poj 3191 The Moronic Cowmpouter
- 黑马程序员--IO,递归总结,
- 小白学开发(iOS)OC_ 可变长度字符串(2015-08-14)