zoukankan      html  css  js  c++  java
  • Kattis

    这里写图片描述

    题意
    从上到下 或者 从左到右 组成的长度 >= 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;
    }
    
  • 相关阅读:
    windows下Qt5.1.0配置android环境搭建 good
    Qt Focus事件,FocusInEvent()与FocusOutEvent()
    Python框架之Django
    WITH (NOLOCK)浅析
    区域、模板页与WebAPI初步
    对象映射工具AutoMapper介绍
    .NET大型B2C开源项目nopcommerce解析——项目结构
    企业管理系统集成
    oracle中sql语句的优化
    C#可扩展编程之MEF
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433280.html
Copyright © 2011-2022 走看看