Codeforces 6B. President's Office
来源:互联网 发布:js如何创建数组 编辑:程序博客网 时间:2024/05/17 06:19
代码:
#include <stdio.h>#include <set>#include <vector>#include <iostream>using namespace std;const int MAXN = 105;char matrix[MAXN][MAXN];bool Hash[256];void Find(int x, int y){ if(isupper(matrix[x][y - 1])) Hash[matrix[x][y - 1]] = true; if(isupper(matrix[x][y + 1])) Hash[matrix[x][y + 1]] = true; if(isupper(matrix[x - 1][y])) Hash[matrix[x - 1][y]] = true; if(isupper(matrix[x + 1][y])) Hash[matrix[x + 1][y]] = true;}int main(){#ifdef _LOCAL freopen("F://input.txt", "r", stdin);#endif int n, m, posX, posY; char ch; scanf("%d%d %c", &n, &m, &ch); vector<pair<int, int>> president; Hash[ch] = true; for(int i = 1; i <= n; ++i) { getchar(); for(int j = 1; j <= m; ++j) { scanf("%c", &matrix[i][j]); if(matrix[i][j] == ch) president.push_back(make_pair(i, j)); } } for(int i = 0; i < president.size(); ++i) Find(president[i].first, president[i].second); int count = 0; for(int i = 'A'; i <= 'Z'; ++i) if(Hash[i]) ++count; printf("%d\n", count - 1); return 0;}
0 0
- codeforces 6B. President's Office
- codeforces 6B President's Office
- Codeforces 6B. President's Office
- CodeForces 6B - President's Office
- CodeForces 6B President's Office
- CodeForces 6B President's Office
- 6B - President's Office
- Codeforces #6B. President's Office (DFS)
- CF 6 B - President's Office
- CF 6B President's Office
- Codeforces Beta Round #6 (Div. 2 Only) B. President's Office
- F - President's Office
- 【非常非常巧妙的暴搜】CodeForce 6B——President's Office
- NEFU要崛起——第5场 B - President's Office
- CF6B: President's Office(简单DFS)
- CodeForces 416E President's Path
- Codeforces 416E President's Path
- codeforces 416E. President's Path( graph dp)
- ArrayList vs. LinkedList vs. Vector
- 查找hive创建的视图
- 数据结构双向链表C++实现
- RHEL6.3克隆虚拟机后的网卡启动失败问题解析
- 数据结构栈的C++实现
- Codeforces 6B. President's Office
- 矩阵连乘
- 数据结构队列C++实现 链式和循环
- XE7 BCB不带Midas.dll发布的方法
- 修改linux主机名称
- pow(x, n),有时递归的时候要注意用变量保存中间结果
- [ZedBoard移植嵌入式Linux教程(4)]创建设备树(Device-Tree)文件dts
- 数据结构二叉查找树C++实现
- Codeforces 6C. Alice, Bob and Chocolate