0
点赞
收藏
分享

微信扫一扫

CF707A Brain's Photos 字符的处理问题 空格 换行

unadlib 2022-06-29 阅读 81

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Input
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’.
Output
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.
Examples
inputCopy
2 2
C M
Y Y
outputCopy
#Color
inputCopy
3 2
W W
W W
B B
outputCopy
#Black&White
inputCopy
1 1
W
outputCopy
#Black&White

思路:这题的难点在于输入。
解决方法用cin 可以忽略空格 和 换行符。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#define ll long long
const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
using namespace std;
int vis[110];
char a;
int main()
{
int n,m;
while(cin>>n>>m)
{
int i;
bool flag=0;
for(i=1; i<=n*m; i++)
{
cin>>a;
if(a=='M'||a=='C'||a=='Y')
flag=1;
}
if(flag)
cout<<"#Color"<<endl;
else
cout<<"#Black&White"<<endl;
}
return 0;
}
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#define ll long long
const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
using namespace std;
int vis[110];
char a[100];
int main()
{
int n,m;
while(cin>>n>>m)
{
int i;
bool flag=0;
for(i=1; i<=n*m; i++)
{
cin>>a[i];
if(a[i]=='M'||a[i]=='C'||a[i]=='Y')//换成数组也可以。
flag=1;
}
if(flag)
cout<<"#Color"<<endl;
else
cout<<"#Black&White"<<endl;
}
return 0;
}


举报

相关推荐

0 条评论