题意

从上到下 或者 从左到右 组成的长度 >= 2 的字符串 如果遇到 # 就断掉

输出 字典序最小的那一个

思路

只要从上到下 和从左到右 分别遍历一遍,将 长度 >= 2 的字符串 保留下来 就可以了

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e2 + 5;
const int MOD = 1e9 + 7; int main()
{
int n, m;
cin >> n >> m;
int i, j;
string s[25], temp;
for (i = 0; i < n; i++)
cin >> s[i];
vector <string> v;
v.clear();
for (i = 0; i < n; i++)
{
temp.clear();
for (j = 0; j < m; j++)
{
if (s[i][j] == '#')
{
if (temp.size() >= 2)
v.push_back(temp);
temp.clear();
}
else
temp += s[i][j];
}
if (temp.size() >= 2)
v.push_back(temp);
}
for (j = 0; j < m; j++)
{
temp.clear();
for (i = 0; i < n; i++)
{
if (s[i][j] == '#')
{
if (temp.size() >= 2)
v.push_back(temp);
temp.clear();
}
else
temp += s[i][j];
}
if (temp.size() >= 2)
v.push_back(temp);
}
sort(v.begin(), v.end());
cout << v[0] << endl;
}

最新文章

  1. 简历生成平台项目开发-STEP2问卷调查结果统计分析
  2. [Tip]重写PanGestureRecognizer
  3. ASP.NET MVC增删改查
  4. $(document).ready()方法的使用
  5. xcodebuild和xcrun实现自动打包iOS应用程序
  6. RejexLib
  7. Android TextView drawableLeft 在代码中实现
  8. 第三课3、ROS的launch文件
  9. log4xx/log4j异步日志配置示例
  10. [C++]Linux之虚拟文件系统[/proc]中关于CPU/内存/网络/内核等的一些概要性说明
  11. git clean(转载)
  12. JVM(二)之GC(转)
  13. OneZero第三周第四次站立会议(2016.4.7)
  14. Rabbit MQ 入门指南
  15. 最好的PHP博客系统
  16. Hibernate学习笔记四
  17. Javascript中判断变量是数组还是对象(array还是object)
  18. 厄拉多塞筛法和普通方法求素数表(python实现)
  19. ios常用的字符串NSString自动释放理解
  20. Selenium(Python)等待元素出现

热门文章

  1. int和Integer差别
  2. 超级拷贝scp
  3. 1211日课后shell总结
  4. Jmeter与LoadRunner 测试Java项目的坑
  5. (分享)Linux服务器如何防止中木马
  6. sql duplicate key
  7. PHP+MySQL:测试连接+基本DB操作
  8. [Spring Framework]学习笔记--Dependency injection(DI)
  9. libnids介
  10. 1624 取余最长路(set)