Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. //707A : BRAIN'S PHOTOS
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.OutputStream;
  8. import java.io.PrintWriter;
  9. import java.util.StringTokenizer;
  10.  
  11. //Your code goes here
  12. public class Main {
  13.  
  14. static class ProblemSolver{
  15. public void solveTheProblem(InputReader in,PrintWriter out){
  16.  
  17. /*
  18. * This is a very simple adhoc question
  19. * involving only character matching
  20. */
  21.  
  22. //User inputs and other variables
  23. int row=in.nextInt();
  24. int col=in.nextInt();
  25. int total=row*col;
  26. String[] pixels=new String[total];
  27. boolean color=false;
  28. for(int i=0;i<total;++i)pixels[i]=in.next();
  29.  
  30. //Evaluation of expression
  31. for(int i=0;i<total;++i){
  32. if(pixels[i].equals("C") || pixels[i].equals("M") || pixels[i].equals("Y")){
  33. color=true;
  34. break;
  35. }
  36. }
  37.  
  38. //Displaying the result
  39. if(color)System.out.println("#Color");
  40. else System.out.println("#Black&White");
  41.  
  42.  
  43.  
  44. }
  45. }
  46.  
  47. //Default template for all the codes
  48. static class InputReader {
  49. public BufferedReader reader;
  50. public StringTokenizer tokenizer;
  51.  
  52. public InputReader(InputStream stream) {
  53. reader = new BufferedReader(new InputStreamReader(stream),32768);
  54. tokenizer = null;
  55. }
  56.  
  57. public String next() {
  58. while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  59. try {
  60. tokenizer = new StringTokenizer(reader.readLine());
  61. } catch (IOException e) {
  62. throw new RuntimeException(e);
  63. }
  64. }
  65. return tokenizer.nextToken();
  66. }
  67.  
  68. public int nextInt() {
  69. return Integer.parseInt(next());
  70. }
  71.  
  72. }
  73.  
  74. //Main method for all the codes
  75. public static void main(String[] args) {
  76. InputStream inputStream = System.in;
  77. OutputStream outputStream = System.out;
  78. InputReader in = new InputReader(inputStream);
  79. PrintWriter out = new PrintWriter(outputStream);
  80. ProblemSolver problemSolver = new ProblemSolver();
  81. problemSolver.solveTheProblem(in, out);
  82. out.close();
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement