zoukankan      html  css  js  c++  java
  • Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos

    题目链接:

    http://codeforces.com/contest/707/problem/A

    Description

    ``` Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.

    As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).

    Brain took a lot of colourful pictures on colored and black-and-white film. Then he developed and translated it into a digital form. But now, color and black-and-white photos are in one folder, and to sort them, one needs to spend more than one hour!

    As soon as Brain is a photographer not programmer now, he asks you to help him determine for a single photo whether it is colored or black-and-white.

    Photo can be represented as a matrix sized n × m, and each element of the matrix stores a symbol indicating corresponding pixel color. There are only 6 colors:

    'C' (cyan)
    'M' (magenta)
    'Y' (yellow)
    'W' (white)
    'G' (grey)
    'B' (black)
    The photo is considered black-and-white if it has only white, black and grey pixels in it. If there are any of cyan, magenta or yellow pixels in the photo then it is considered colored.

    </big>
    
    
     
    
    
    
    
    ##Input
    <big>
    

    The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of photo pixel matrix rows and columns respectively.
    Then n lines describing matrix rows follow. Each of them contains m space-separated characters describing colors of pixels in a row. Each character in the line is one of the 'C', 'M', 'Y', 'W', 'G' or 'B'.

    </big>
    
    
    
    
    
    
    ##Output
    <big>
    

    Print the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line.

    </big>
    
    
     
     
    ##Examples
    <big>
    

    input
    2 2
    C M
    Y Y
    output

    Color

    input
    3 2
    W W
    W W
    B B
    output

    Black&White

    input
    1 1
    W
    output

    Black&White

    </big>
    
    
    ##Source
    <big>
    Codeforces Round #368 (Div. 2)
    </big>
    
    
    
    
    <br/>
    ##题意:
    <big>
    判断给出的图形(像素点)是否是有色图形.
    </big>
    
    
    <br/>
    ##题解:
    <big>
    水题. 注意字符的读入、不要漏掉'G'即可.
    </big>
    
    
    
    
    <br/>
    ##代码:
    ``` cpp
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <set>
    #include <stack>
    #include <vector>
    #include <list>
    #define LL long long
    #define eps 1e-8
    #define maxn 1010
    #define mod 100000007
    #define inf 0x3f3f3f3f
    #define mid(a,b) ((a+b)>>1)
    #define IN freopen("in.txt","r",stdin);
    using namespace std;
    
    int n,m;
    char str[550];
    
    int main(int argc, char const *argv[])
    {
        //IN;
    
        while(scanf("%d %d", &n,&m) != EOF)
        {
            bool flag = 1;
            for(int i=1; i<=n; i++) {
                for(int j=1; j<=m; j++) {
                    getchar();
                    char c = getchar();
                    if(c!='W' && c!='B' && c!='G')
                        flag = 0;
                }
            }
    
            if(flag) puts("#Black&White");
            else puts("#Color");
        }
    
        return 0;
    }
    
  • 相关阅读:
    数据结构与算法(C++)之swap交换
    常用shell脚本
    Java知识库
    jenkins:你们是怎么在控制台实时打印服务启动日志的?
    mqtt压力测试工具emqtt
    postman中获取环境变量和全局变量
    不想当将军的士兵不是好士兵吗?
    永久关闭火狐浏览器自动更新的方法
    性能测试案例:线程池拒绝策略使用不当导致并发一上去就会出现大量报错
    性能测试案例:一个频繁fgc问题
  • 原文地址:https://www.cnblogs.com/Sunshine-tcf/p/5792453.html
Copyright © 2011-2022 走看看